mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 04:10:18 +09:00
atv_demod: Modify atv sys for search and optimize code.
PD#164878: Modify atv sys for search and optimize code. Change-Id: I4ba7c6c38a742ebfe9cb8488277b0d04cf12230e Signed-off-by: nengwen.chen <nengwen.chen@amlogic.com>
This commit is contained in:
@@ -57,7 +57,8 @@ static ssize_t aml_atvdemod_store(struct class *class,
|
||||
unsigned long tmp = 0;
|
||||
struct aml_atvdemod_device *aml_atvdemod_dev = NULL;
|
||||
|
||||
aml_atvdemod_dev = container_of(class, struct aml_atvdemod_device, cls);
|
||||
aml_atvdemod_dev = container_of(&class,
|
||||
struct aml_atvdemod_device, cls);
|
||||
|
||||
buf_orig = kstrdup(buf, GFP_KERNEL);
|
||||
ps = buf_orig;
|
||||
@@ -214,52 +215,48 @@ static ssize_t aml_atvdemod_store(struct class *class,
|
||||
|
||||
retrieve_vpll_carrier_lock(&vpll_lock);
|
||||
if ((vpll_lock & 0x1) == 0)
|
||||
pr_dbg("visual carrier lock:locked\n");
|
||||
pr_info("visual carrier lock:locked\n");
|
||||
else
|
||||
pr_dbg("visual carrier lock:unlocked\n");
|
||||
pr_info("visual carrier lock:unlocked\n");
|
||||
} else if (!strncmp(parm[0], "line_lock", 9)) {
|
||||
int line_lock;
|
||||
|
||||
retrieve_vpll_carrier_line_lock(&line_lock);
|
||||
if (line_lock == 0)
|
||||
pr_dbg("line lock:locked\n");
|
||||
pr_info("line lock:locked\n");
|
||||
else
|
||||
pr_dbg("line lock:unlocked\n");
|
||||
pr_info("line lock:unlocked\n");
|
||||
} else if (!strncmp(parm[0], "audio_power", 11)) {
|
||||
int audio_power = 0;
|
||||
|
||||
retrieve_vpll_carrier_audio_power(&audio_power);
|
||||
pr_info("audio_power: %d.\n", audio_power);
|
||||
} else if (!strncmp(parm[0], "adc_power", 9)) {
|
||||
int adc_power = 0;
|
||||
|
||||
retrieve_adc_power(&adc_power);
|
||||
pr_dbg("adc_power:%d\n", adc_power);
|
||||
} else if (!strncmp(parm[0], "search_atv", 10)) {
|
||||
unsigned int freq = 0;
|
||||
struct analog_parameters params;
|
||||
struct dvb_frontend *fe = NULL;
|
||||
pr_info("adc_power:%d\n", adc_power);
|
||||
} else if (!strncmp(parm[0], "demod_set", 9)) {
|
||||
|
||||
fe = &aml_atvdemod_dev->v4l2_fe.v4l2_ad->fe;
|
||||
|
||||
if (kstrtoul(parm[1], 10, &tmp) == 0)
|
||||
freq = tmp;
|
||||
|
||||
params.frequency = freq;
|
||||
params.mode = 1;
|
||||
params.audmode = 0;
|
||||
params.std = V4L2_STD_PAL_I;
|
||||
|
||||
fe->ops.analog_ops.set_params(fe, ¶ms);
|
||||
} else if (!strncmp(parm[0], "mode_set", 8)) {
|
||||
int priv_cfg = AML_ATVDEMOD_INIT;
|
||||
struct dvb_frontend *fe = NULL;
|
||||
|
||||
fe = &aml_atvdemod_dev->v4l2_fe.v4l2_ad->fe;
|
||||
if (aml_atvdemod_dev == NULL)
|
||||
pr_info("aml_atvdemod_dev == NULL\n");
|
||||
|
||||
fe = &aml_atvdemod_dev->v4l2_fe.fe;
|
||||
|
||||
if (kstrtoul(parm[1], 10, &tmp) == 0)
|
||||
priv_cfg = tmp;
|
||||
|
||||
fe->ops.analog_ops.set_config(fe, &priv_cfg);
|
||||
if (fe != NULL) {
|
||||
if (fe->ops.analog_ops.set_config != NULL)
|
||||
fe->ops.analog_ops.set_config(fe, &priv_cfg);
|
||||
else
|
||||
pr_info("fe->ops.analog_ops.set_config == NULL\n");
|
||||
} else
|
||||
pr_info("fe == NULL\n");
|
||||
} else
|
||||
pr_dbg("invalid command\n");
|
||||
|
||||
@@ -282,11 +279,17 @@ static ssize_t aml_atvdemod_show(struct class *cls,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct class_attribute atvdemod_debug_class_attrs[] = {
|
||||
static struct class_attribute aml_atvdemod_attrs[] = {
|
||||
__ATTR(atvdemod_debug, 0644, aml_atvdemod_show, aml_atvdemod_store),
|
||||
__ATTR_NULL
|
||||
};
|
||||
|
||||
struct class aml_atvdemod_class = {
|
||||
.name = ATVDEMOD_DEVICE_NAME,
|
||||
.owner = THIS_MODULE,
|
||||
.class_attrs = aml_atvdemod_attrs,
|
||||
};
|
||||
|
||||
static void aml_atvdemod_dt_parse(struct aml_atvdemod_device *pdev)
|
||||
{
|
||||
struct device_node *node = NULL;
|
||||
@@ -318,7 +321,10 @@ static void aml_atvdemod_dt_parse(struct aml_atvdemod_device *pdev)
|
||||
/* agc pin mux */
|
||||
ret = of_property_read_string(node, "pinctrl-names",
|
||||
&pdev->pin_name);
|
||||
if (!ret) {
|
||||
if (ret) {
|
||||
pdev->pin = NULL;
|
||||
pr_err("can't find agc pinmux.\n");
|
||||
} else {
|
||||
#if 0
|
||||
amlatvdemod_devp->pin = devm_pinctrl_get_select(
|
||||
&pdev->dev, pdev->pin_name);
|
||||
@@ -341,6 +347,8 @@ static void aml_atvdemod_dt_parse(struct aml_atvdemod_device *pdev)
|
||||
pdev->tuner_id = AM_TUNER_MXL661;
|
||||
else if (!strncmp(str, "si2151_tuner", 12))
|
||||
pdev->tuner_id = AM_TUNER_SI2151;
|
||||
else if (!strncmp(str, "si2159_tuner", 12))
|
||||
pdev->tuner_id = AM_TUNER_SI2159;
|
||||
else if (!strncmp(str, "r840_tuner", 10))
|
||||
pdev->tuner_id = AM_TUNER_R840;
|
||||
else
|
||||
@@ -370,6 +378,55 @@ static void aml_atvdemod_dt_parse(struct aml_atvdemod_device *pdev)
|
||||
}
|
||||
}
|
||||
|
||||
int aml_attach_demod_tuner(struct aml_atvdemod_device *dev)
|
||||
{
|
||||
void *p = NULL;
|
||||
struct v4l2_frontend *v4l2_fe = &dev->v4l2_fe;
|
||||
struct dvb_frontend *fe = &v4l2_fe->fe;
|
||||
|
||||
if (!dev->analog_attached) {
|
||||
p = v4l2_attach(aml_atvdemod_attach, fe,
|
||||
dev->i2c_adp, dev->i2c_addr, dev->tuner_id);
|
||||
if (p != NULL)
|
||||
dev->analog_attached = true;
|
||||
else {
|
||||
pr_err("%s: attach demod error.\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
p = NULL;
|
||||
|
||||
if (!dev->tuner_attached) {
|
||||
switch (dev->tuner_id) {
|
||||
case AM_TUNER_R840:
|
||||
break;
|
||||
case AM_TUNER_SI2151:
|
||||
p = v4l2_attach(si2151_attach, fe,
|
||||
dev->i2c_adp, dev->i2c_addr);
|
||||
break;
|
||||
case AM_TUNER_SI2159:
|
||||
p = v4l2_attach(si2159_attach, fe,
|
||||
dev->i2c_adp, dev->i2c_addr);
|
||||
break;
|
||||
case AM_TUNER_MXL661:
|
||||
p = v4l2_attach(mxl661_attach, fe,
|
||||
dev->i2c_adp, dev->i2c_addr);
|
||||
break;
|
||||
}
|
||||
|
||||
if (p != NULL)
|
||||
dev->tuner_attached = true;
|
||||
else {
|
||||
pr_err("%s: attach tuner [%d] error.\n",
|
||||
__func__, dev->tuner_id);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int aml_atvdemod_probe(struct platform_device *pdev)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -383,24 +440,7 @@ static int aml_atvdemod_probe(struct platform_device *pdev)
|
||||
return -ENOMEM;
|
||||
|
||||
dev->name = ATVDEMOD_DEVICE_NAME;
|
||||
dev->cls.name = ATVDEMOD_DEVICE_NAME;
|
||||
#if 0
|
||||
dev->cls.name = devm_kmalloc(&pdev->dev, sizeof(ATVDEMOD_DEVICE_NAME),
|
||||
GFP_KERNEL);
|
||||
if (!dev->cls.name)
|
||||
return -ENOMEM;
|
||||
|
||||
snprintf((char *)dev->cls.name, sizeof(ATVDEMOD_DEVICE_NAME), "%s",
|
||||
ATVDEMOD_DEVICE_NAME);
|
||||
#endif
|
||||
|
||||
dev->cls.class_attrs = atvdemod_debug_class_attrs;
|
||||
ret = class_register(&dev->cls);
|
||||
if (ret) {
|
||||
pr_err("class_create fail.\n");
|
||||
goto fail_create_class;
|
||||
}
|
||||
|
||||
dev->cls = &aml_atvdemod_class;
|
||||
dev->dev = &pdev->dev;
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
@@ -455,13 +495,14 @@ static int aml_atvdemod_probe(struct platform_device *pdev)
|
||||
|
||||
aml_atvdemod_dt_parse(dev);
|
||||
|
||||
dev->v4l2_ad.dev = dev->dev;
|
||||
dev->v4l2_ad.i2c.addr = dev->i2c_addr;
|
||||
dev->v4l2_ad.i2c.adapter = dev->i2c_adp;
|
||||
/* i2c_get_adapter(dev->i2c_adapter_id); */
|
||||
dev->v4l2_ad.tuner_id = dev->tuner_id;
|
||||
ret = v4l2_resister_frontend(&dev->v4l2_ad, &dev->v4l2_fe);
|
||||
if (ret) {
|
||||
aml_attach_demod_tuner(dev);
|
||||
|
||||
dev->v4l2_fe.dev = dev->dev;
|
||||
dev->v4l2_fe.tuner_id = dev->tuner_id;
|
||||
dev->v4l2_fe.i2c.addr = dev->i2c_addr;
|
||||
dev->v4l2_fe.i2c.adapter = dev->i2c_adp;
|
||||
ret = v4l2_resister_frontend(&dev->v4l2_fe);
|
||||
if (ret < 0) {
|
||||
pr_err("resister v4l2 fail.\n");
|
||||
goto fail_register_v4l2;
|
||||
}
|
||||
@@ -476,8 +517,6 @@ static int aml_atvdemod_probe(struct platform_device *pdev)
|
||||
|
||||
fail_register_v4l2:
|
||||
fail_get_resource:
|
||||
class_unregister(&dev->cls);
|
||||
fail_create_class:
|
||||
/*devm_kfree(&pdev->dev, dev->cls.name);*/
|
||||
devm_kfree(&pdev->dev, dev);
|
||||
|
||||
@@ -493,8 +532,6 @@ static int aml_atvdemod_remove(struct platform_device *pdev)
|
||||
if (dev == NULL)
|
||||
return -1;
|
||||
|
||||
class_unregister(&dev->cls);
|
||||
|
||||
v4l2_unresister_frontend(&dev->v4l2_fe);
|
||||
|
||||
amlatvdemod_devp = NULL;
|
||||
@@ -558,9 +595,17 @@ static struct platform_driver aml_atvdemod_driver = {
|
||||
|
||||
static int __init aml_atvdemod_init(void)
|
||||
{
|
||||
if (platform_driver_register(&aml_atvdemod_driver)) {
|
||||
int ret = 0;
|
||||
|
||||
ret = class_register(&aml_atvdemod_class);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = platform_driver_register(&aml_atvdemod_driver);
|
||||
if (ret < 0) {
|
||||
pr_err("%s: failed to register driver.\n", __func__);
|
||||
return -ENODEV;
|
||||
class_unregister(&aml_atvdemod_class);
|
||||
return ret;
|
||||
}
|
||||
|
||||
pr_info("%s: OK.\n", __func__);
|
||||
@@ -571,6 +616,8 @@ static int __init aml_atvdemod_init(void)
|
||||
static void __exit aml_atvdemod_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&aml_atvdemod_driver);
|
||||
class_unregister(&aml_atvdemod_class);
|
||||
|
||||
pr_info("%s: OK.\n", __func__);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,20 +20,6 @@ extern int atvdemod_debug_en;
|
||||
#include "drivers/media/dvb-core/dvb_frontend.h"
|
||||
#include "atv_demod_v4l2.h"
|
||||
|
||||
enum aml_tuner_type_t {
|
||||
AM_TUNER_SI2176 = 1,
|
||||
AM_TUNER_SI2196 = 2,
|
||||
AM_TUNER_FQ1216 = 3,
|
||||
AM_TUNER_HTM = 4,
|
||||
AM_TUNER_CTC703 = 5,
|
||||
AM_TUNER_SI2177 = 6,
|
||||
AM_TUNER_R840 = 7,
|
||||
AM_TUNER_SI2157 = 8,
|
||||
AM_TUNER_SI2151 = 9,
|
||||
AM_TUNER_MXL661 = 10,
|
||||
AM_TUNER_MXL608 = 11
|
||||
};
|
||||
|
||||
struct aml_atvdemod_parameters {
|
||||
|
||||
struct analog_parameters param;
|
||||
@@ -51,7 +37,7 @@ struct aml_atvdemod_parameters {
|
||||
|
||||
struct aml_atvdemod_device {
|
||||
char *name;
|
||||
struct class cls;
|
||||
struct class *cls;
|
||||
struct device *dev;
|
||||
|
||||
unsigned int tuner_id;
|
||||
@@ -67,8 +53,9 @@ struct aml_atvdemod_device {
|
||||
struct pinctrl *pin;
|
||||
const char *pin_name;
|
||||
|
||||
struct v4l2_adapter v4l2_ad;
|
||||
struct v4l2_frontend v4l2_fe;
|
||||
bool analog_attached;
|
||||
bool tuner_attached;
|
||||
|
||||
void __iomem *demod_reg_base;
|
||||
void __iomem *audio_reg_base;
|
||||
@@ -98,4 +85,6 @@ struct aml_atvdemod_device {
|
||||
|
||||
extern struct aml_atvdemod_device *amlatvdemod_devp;
|
||||
|
||||
extern int aml_attach_demod_tuner(struct aml_atvdemod_device *dev);
|
||||
|
||||
#endif /* __ATV_DEMOD_DRIVER_H__ */
|
||||
|
||||
@@ -205,6 +205,8 @@ int atv_demod_enter_mode(void)
|
||||
* memset(&(amlatvdemod_devp->parm), 0,
|
||||
* sizeof(amlatvdemod_devp->parm));
|
||||
*/
|
||||
amlatvdemod_devp->std = 0;
|
||||
|
||||
atvdemod_state = ATVDEMOD_STATE_WORK;
|
||||
|
||||
pr_info("%s: OK.\n", __func__);
|
||||
@@ -232,6 +234,7 @@ int atv_demod_leave_mode(void)
|
||||
* memset(&(amlatvdemod_devp->parm), 0,
|
||||
* sizeof(amlatvdemod_devp->parm));
|
||||
*/
|
||||
amlatvdemod_devp->std = 0;
|
||||
atvdemod_state = ATVDEMOD_STATE_IDEL;
|
||||
|
||||
pr_info("%s: OK.\n", __func__);
|
||||
@@ -273,6 +276,7 @@ static void atv_demod_set_params(struct dvb_frontend *fe,
|
||||
/* open AGC if needed */
|
||||
if (amlatvdemod_devp->pin != NULL)
|
||||
devm_pinctrl_put(amlatvdemod_devp->pin);
|
||||
|
||||
if (amlatvdemod_devp->pin_name)
|
||||
amlatvdemod_devp->pin =
|
||||
devm_pinctrl_get_select(amlatvdemod_devp->dev,
|
||||
@@ -295,9 +299,11 @@ static void atv_demod_set_params(struct dvb_frontend *fe,
|
||||
if (!is_atvdemod_scan_mode())
|
||||
atvauddemod_init();
|
||||
|
||||
pr_info("%s: set std color %lld, audio type %lld.\n",
|
||||
__func__, amlatvdemod_devp->std, amlatvdemod_devp->std);
|
||||
pr_info("%s: set if_freq %d, if_inv %d.\n",
|
||||
pr_info("[%s] set std color %s, audio type %s.\n",
|
||||
__func__,
|
||||
v4l2_std_to_str((0xff000000 & amlatvdemod_devp->std)),
|
||||
v4l2_std_to_str((0xffffff & amlatvdemod_devp->std)));
|
||||
pr_info("[%s] set if_freq %d, if_inv %d.\n",
|
||||
__func__, amlatvdemod_devp->if_freq,
|
||||
amlatvdemod_devp->if_inv);
|
||||
}
|
||||
@@ -441,7 +447,6 @@ struct dvb_frontend *aml_atvdemod_attach(struct dvb_frontend *fe,
|
||||
struct i2c_adapter *i2c_adap, u8 i2c_addr, u32 tuner_id)
|
||||
{
|
||||
int instance = 0;
|
||||
void *p = NULL;
|
||||
struct atv_demod_priv *priv = NULL;
|
||||
|
||||
mutex_lock(&atv_demod_list_mutex);
|
||||
@@ -473,20 +478,6 @@ struct dvb_frontend *aml_atvdemod_attach(struct dvb_frontend *fe,
|
||||
memcpy(&fe->ops.analog_ops, &atvdemod_ops,
|
||||
sizeof(struct analog_demod_ops));
|
||||
|
||||
switch (tuner_id) {
|
||||
case AM_TUNER_R840:
|
||||
break;
|
||||
case AM_TUNER_SI2151:
|
||||
p = v4l2_attach(si2151_attach, fe, i2c_adap, i2c_addr);
|
||||
break;
|
||||
case AM_TUNER_MXL661:
|
||||
p = v4l2_attach(mxl661_attach, fe, i2c_adap, i2c_addr);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!p)
|
||||
pr_err("%s: v4l2_attach tuner %d error.\n",
|
||||
__func__, tuner_id);
|
||||
|
||||
return fe;
|
||||
}
|
||||
EXPORT_SYMBOL(aml_atvdemod_attach);
|
||||
|
||||
@@ -37,9 +37,4 @@ extern int atv_demod_enter_mode(void);
|
||||
struct dvb_frontend *aml_atvdemod_attach(struct dvb_frontend *fe,
|
||||
struct i2c_adapter *i2c_adap, u8 i2c_addr, u32 tuner_id);
|
||||
|
||||
extern struct dvb_frontend *mxl661_attach(struct dvb_frontend *fe,
|
||||
struct i2c_adapter *i2c_adap, u8 i2c_addr);
|
||||
extern struct dvb_frontend *si2151_attach(struct dvb_frontend *fe,
|
||||
struct i2c_adapter *i2c_adap, u8 i2c_addr);
|
||||
|
||||
#endif /* __ATV_DEMOD_OPS_H__ */
|
||||
|
||||
@@ -114,7 +114,7 @@ static v4l2_std_id demod_fmt_2_v4l2_std(int fmt)
|
||||
static v4l2_std_id trans_tvin_fmt_to_v4l2_std(int fmt)
|
||||
{
|
||||
v4l2_std_id std = 0;
|
||||
|
||||
#if 0 /* Want to remove ours define V4L2_COLOR_STD_NTSC/PAL/SECAM.*/
|
||||
switch (fmt) {
|
||||
case TVIN_SIG_FMT_CVBS_NTSC_M:
|
||||
std = V4L2_STD_NTSC;
|
||||
@@ -141,6 +141,30 @@ static v4l2_std_id trans_tvin_fmt_to_v4l2_std(int fmt)
|
||||
pr_err("%s: Unsupport fmt: 0x%x\n", __func__, fmt);
|
||||
break;
|
||||
}
|
||||
#else
|
||||
switch (fmt) {
|
||||
case TVIN_SIG_FMT_CVBS_NTSC_M:
|
||||
case TVIN_SIG_FMT_CVBS_NTSC_443:
|
||||
case TVIN_SIG_FMT_CVBS_NTSC_50:
|
||||
std = V4L2_COLOR_STD_NTSC;
|
||||
break;
|
||||
|
||||
case TVIN_SIG_FMT_CVBS_PAL_I:
|
||||
case TVIN_SIG_FMT_CVBS_PAL_M:
|
||||
case TVIN_SIG_FMT_CVBS_PAL_60:
|
||||
case TVIN_SIG_FMT_CVBS_PAL_CN:
|
||||
std = V4L2_COLOR_STD_PAL;
|
||||
break;
|
||||
|
||||
case TVIN_SIG_FMT_CVBS_SECAM:
|
||||
std = V4L2_COLOR_STD_SECAM;
|
||||
break;
|
||||
default:
|
||||
pr_err("%s Unsupport fmt: 0x%x\n", __func__, fmt);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
return std;
|
||||
}
|
||||
|
||||
@@ -148,7 +172,7 @@ static void v4l2_fe_try_analog_format(struct v4l2_frontend *v4l2_fe,
|
||||
bool auto_search_std, v4l2_std_id *video_fmt,
|
||||
unsigned int *audio_fmt)
|
||||
{
|
||||
struct dvb_frontend *fe = &v4l2_fe->v4l2_ad->fe;
|
||||
struct dvb_frontend *fe = &v4l2_fe->fe;
|
||||
struct v4l2_analog_parameters *p = &v4l2_fe->params;
|
||||
struct analog_parameters params;
|
||||
int i = 0;
|
||||
@@ -170,7 +194,7 @@ static void v4l2_fe_try_analog_format(struct v4l2_frontend *v4l2_fe,
|
||||
pr_dbg("get varify_cnt:%d, cnt:%d, std_bk:0x%x\n",
|
||||
varify_cnt, i,
|
||||
(unsigned int) std_bk);
|
||||
if ((v4l2_fe->v4l2_ad->tuner_id == AM_TUNER_R840
|
||||
if ((v4l2_fe->tuner_id == AM_TUNER_R840
|
||||
&& varify_cnt > 0)
|
||||
|| varify_cnt > 3)
|
||||
break;
|
||||
@@ -182,12 +206,15 @@ static void v4l2_fe_try_analog_format(struct v4l2_frontend *v4l2_fe,
|
||||
* need set the std,
|
||||
* then, try others std.
|
||||
*/
|
||||
if (p->std & V4L2_STD_PAL)
|
||||
p->std = V4L2_STD_NTSC_M;
|
||||
else if (p->std & V4L2_STD_NTSC)
|
||||
p->std = V4L2_STD_SECAM_L;
|
||||
else if (p->std & V4L2_STD_SECAM)
|
||||
p->std = V4L2_STD_PAL_DK;
|
||||
if (p->std & V4L2_COLOR_STD_PAL)
|
||||
p->std = V4L2_COLOR_STD_NTSC
|
||||
| V4L2_STD_NTSC_M;
|
||||
else if (p->std & V4L2_COLOR_STD_NTSC)
|
||||
p->std = V4L2_COLOR_STD_SECAM
|
||||
| V4L2_STD_SECAM;
|
||||
else if (p->std & V4L2_COLOR_STD_SECAM)
|
||||
p->std = V4L2_COLOR_STD_PAL
|
||||
| V4L2_STD_PAL_DK;
|
||||
|
||||
p->frequency += 1;
|
||||
params.frequency = p->frequency;
|
||||
@@ -207,8 +234,10 @@ static void v4l2_fe_try_analog_format(struct v4l2_frontend *v4l2_fe,
|
||||
pr_err("%s: failed to get video fmt, assume PAL.\n",
|
||||
__func__);
|
||||
std_bk = TVIN_SIG_FMT_CVBS_PAL_I;
|
||||
p->std = V4L2_STD_PAL_I;
|
||||
p->std = V4L2_COLOR_STD_PAL | V4L2_STD_PAL_DK;
|
||||
p->frequency += 1;
|
||||
p->audmode = V4L2_STD_PAL_DK;
|
||||
|
||||
params.frequency = p->frequency;
|
||||
params.mode = p->flag;
|
||||
params.audmode = p->audmode;
|
||||
@@ -229,11 +258,13 @@ static void v4l2_fe_try_analog_format(struct v4l2_frontend *v4l2_fe,
|
||||
|
||||
*video_fmt = std_bk;
|
||||
|
||||
if (std_bk == V4L2_STD_NTSC) {
|
||||
#if 0 /* For TV Signal Generator(TG39) test, NTSC need support other audio.*/
|
||||
amlatvdemod_set_std(AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_DK);
|
||||
if (std_bk == V4L2_COLOR_STD_NTSC) {
|
||||
#if 1 /* For TV Signal Generator(TG39) test, NTSC need support other audio.*/
|
||||
amlatvdemod_set_std(AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_DK);
|
||||
audio = aml_audiomode_autodet(fe);
|
||||
pr_info("autodet audmode 0x%x\n", audio);
|
||||
audio = demod_fmt_2_v4l2_std(audio);
|
||||
pr_info("v4l2_std audmode 0x%x\n", audio);
|
||||
#if 0
|
||||
if (audio == V4L2_STD_PAL_M)
|
||||
audio = V4L2_STD_NTSC_M;
|
||||
@@ -242,11 +273,10 @@ static void v4l2_fe_try_analog_format(struct v4l2_frontend *v4l2_fe,
|
||||
#endif
|
||||
#else /* Now, force to NTSC_M, Ours demod only support M for NTSC.*/
|
||||
audio = V4L2_STD_NTSC_M;
|
||||
*video_fmt |= V4L2_COLOR_STD_NTSC;
|
||||
*video_fmt |= V4L2_STD_NTSC_M;
|
||||
#endif
|
||||
} else if (std_bk == V4L2_STD_SECAM) {
|
||||
} else if (std_bk == V4L2_COLOR_STD_SECAM) {
|
||||
audio = V4L2_STD_SECAM_L;
|
||||
*video_fmt |= V4L2_COLOR_STD_SECAM;
|
||||
} else {
|
||||
/*V4L2_COLOR_STD_PAL*/
|
||||
*video_fmt |= V4L2_COLOR_STD_PAL;
|
||||
@@ -263,13 +293,14 @@ static void v4l2_fe_try_analog_format(struct v4l2_frontend *v4l2_fe,
|
||||
#endif
|
||||
}
|
||||
|
||||
*video_fmt |= audio;
|
||||
*audio_fmt = audio;
|
||||
}
|
||||
|
||||
static int v4l2_fe_afc_closer(struct v4l2_frontend *v4l2_fe, int minafcfreq,
|
||||
int maxafcfreq, int isAutoSearch)
|
||||
{
|
||||
struct dvb_frontend *fe = &v4l2_fe->v4l2_ad->fe;
|
||||
struct dvb_frontend *fe = &v4l2_fe->fe;
|
||||
struct v4l2_analog_parameters *p = &v4l2_fe->params;
|
||||
struct analog_parameters params;
|
||||
int afc = 100;
|
||||
@@ -280,6 +311,7 @@ static int v4l2_fe_afc_closer(struct v4l2_frontend *v4l2_fe, int minafcfreq,
|
||||
static int temp_freq, temp_afc;
|
||||
struct timespec time_now;
|
||||
static struct timespec success_time;
|
||||
unsigned int tuner_id = v4l2_fe->tuner_id;
|
||||
|
||||
pr_dbg("[%s] freq_success: %d, freq: %d, minfreq: %d, maxfreq: %d\n",
|
||||
__func__, freq_success, p->frequency, minafcfreq, maxafcfreq);
|
||||
@@ -301,16 +333,18 @@ static int v4l2_fe_afc_closer(struct v4l2_frontend *v4l2_fe, int minafcfreq,
|
||||
|
||||
set_freq = p->frequency;
|
||||
while (abs(afc) > AFC_BEST_LOCK) {
|
||||
if (v4l2_fe->v4l2_ad->tuner_id == AM_TUNER_SI2151 ||
|
||||
v4l2_fe->v4l2_ad->tuner_id == AM_TUNER_R840)
|
||||
if (tuner_id == AM_TUNER_SI2151 ||
|
||||
tuner_id == AM_TUNER_SI2159 ||
|
||||
tuner_id == AM_TUNER_R840)
|
||||
usleep_range(20 * 1000, 20 * 1000 + 100);
|
||||
else if (v4l2_fe->v4l2_ad->tuner_id == AM_TUNER_MXL661)
|
||||
else if (tuner_id == AM_TUNER_MXL661)
|
||||
usleep_range(30 * 1000, 30 * 1000 + 100);
|
||||
|
||||
if (fe->ops.analog_ops.get_afc &&
|
||||
((v4l2_fe->v4l2_ad->tuner_id == AM_TUNER_R840) ||
|
||||
(v4l2_fe->v4l2_ad->tuner_id == AM_TUNER_SI2151) ||
|
||||
(v4l2_fe->v4l2_ad->tuner_id == AM_TUNER_MXL661)))
|
||||
((tuner_id == AM_TUNER_R840) ||
|
||||
(tuner_id == AM_TUNER_SI2151) ||
|
||||
(tuner_id == AM_TUNER_SI2159) ||
|
||||
(tuner_id == AM_TUNER_MXL661)))
|
||||
fe->ops.analog_ops.get_afc(fe, &afc);
|
||||
else if (fe->ops.tuner_ops.get_afc)
|
||||
fe->ops.tuner_ops.get_afc(fe, &afc);
|
||||
@@ -399,7 +433,7 @@ static int v4l2_fe_afc_closer(struct v4l2_frontend *v4l2_fe, int minafcfreq,
|
||||
static enum v4l2_search v4l2_frontend_search(struct v4l2_frontend *v4l2_fe)
|
||||
{
|
||||
struct analog_parameters params;
|
||||
struct dvb_frontend *fe = &v4l2_fe->v4l2_ad->fe;
|
||||
struct dvb_frontend *fe = &v4l2_fe->fe;
|
||||
struct v4l2_analog_parameters *p = &v4l2_fe->params;
|
||||
enum v4l2_status tuner_state = V4L2_TIMEDOUT;
|
||||
enum v4l2_status ade_state = V4L2_TIMEDOUT;
|
||||
@@ -415,6 +449,7 @@ static enum v4l2_search v4l2_frontend_search(struct v4l2_frontend *v4l2_fe)
|
||||
bool auto_search_std = false;
|
||||
int search_count = 0;
|
||||
int ret = -1;
|
||||
unsigned int tuner_id = v4l2_fe->tuner_id;
|
||||
|
||||
#ifdef DEBUG_TIME_CUS
|
||||
unsigned int time_start, time_end, time_delta;
|
||||
@@ -435,7 +470,7 @@ static enum v4l2_search v4l2_frontend_search(struct v4l2_frontend *v4l2_fe)
|
||||
}
|
||||
|
||||
pr_info("[%s] afc_range: [%d], tuner: [%d], freq: [%d], flag: [%d].\n",
|
||||
__func__, p->afc_range, v4l2_fe->v4l2_ad->tuner_id,
|
||||
__func__, p->afc_range, tuner_id,
|
||||
p->frequency, p->flag);
|
||||
|
||||
/* backup the freq by api */
|
||||
@@ -446,9 +481,9 @@ static enum v4l2_search v4l2_frontend_search(struct v4l2_frontend *v4l2_fe)
|
||||
* and need tvafe identify signal type.
|
||||
*/
|
||||
if (p->std == 0) {
|
||||
p->std = V4L2_STD_PAL_I;
|
||||
p->std = V4L2_COLOR_STD_PAL | V4L2_STD_PAL_DK;
|
||||
auto_search_std = true;
|
||||
pr_dbg("[%s] user analog.std is 0, so set it to PAL | I.\n",
|
||||
pr_dbg("[%s] user analog.std is 0, so set it to PAL | DK.\n",
|
||||
__func__);
|
||||
}
|
||||
|
||||
@@ -462,7 +497,7 @@ static enum v4l2_search v4l2_frontend_search(struct v4l2_frontend *v4l2_fe)
|
||||
|
||||
/*from the current freq start, and set the afc_step*/
|
||||
/*if step is 2Mhz,r840 will miss program*/
|
||||
if (slow_mode || (v4l2_fe->v4l2_ad->tuner_id == AM_TUNER_R840)
|
||||
if (slow_mode || (tuner_id == AM_TUNER_R840)
|
||||
|| (p->afc_range == ATV_AFC_1_0MHZ)) {
|
||||
pr_dbg("[%s] slow mode to search the channel\n", __func__);
|
||||
afc_step = ATV_AFC_1_0MHZ;
|
||||
@@ -501,15 +536,14 @@ static enum v4l2_search v4l2_frontend_search(struct v4l2_frontend *v4l2_fe)
|
||||
pll_lock = false;
|
||||
tuner_status_cnt_local = tuner_status_cnt;
|
||||
do {
|
||||
if (v4l2_fe->v4l2_ad->tuner_id == AM_TUNER_MXL661) {
|
||||
if (tuner_id == AM_TUNER_MXL661) {
|
||||
usleep_range(30 * 1000, 30 * 1000 + 100);
|
||||
} else if (v4l2_fe->v4l2_ad->tuner_id
|
||||
== AM_TUNER_R840) {
|
||||
} else if (tuner_id == AM_TUNER_R840) {
|
||||
usleep_range(20 * 1000, 20 * 1000 + 100);
|
||||
fe->ops.tuner_ops.get_status(fe,
|
||||
&tuner_state);
|
||||
} else {
|
||||
/*fee->tuner->drv->id == AM_TUNER_SI2151)*/
|
||||
/* AM_TUNER_SI2151 and AM_TUNER_SI2159 */
|
||||
usleep_range(10 * 1000, 10 * 1000 + 100);
|
||||
}
|
||||
|
||||
@@ -517,12 +551,10 @@ static enum v4l2_search v4l2_frontend_search(struct v4l2_frontend *v4l2_fe)
|
||||
tuner_status_cnt_local--;
|
||||
if (((ade_state == V4L2_HAS_LOCK ||
|
||||
tuner_state == V4L2_HAS_LOCK) &&
|
||||
(v4l2_fe->v4l2_ad->tuner_id
|
||||
!= AM_TUNER_R840)) ||
|
||||
(tuner_id != AM_TUNER_R840)) ||
|
||||
((ade_state == V4L2_HAS_LOCK &&
|
||||
tuner_state == V4L2_HAS_LOCK) &&
|
||||
(v4l2_fe->v4l2_ad->tuner_id
|
||||
== AM_TUNER_R840))) {
|
||||
(tuner_id == AM_TUNER_R840))) {
|
||||
pll_lock = true;
|
||||
break;
|
||||
}
|
||||
@@ -917,7 +949,7 @@ static int v4l2_set_frontend(struct v4l2_frontend *v4l2_fe,
|
||||
u32 freq_max = 0;
|
||||
struct analog_parameters p;
|
||||
struct v4l2_frontend_private *fepriv = v4l2_fe->frontend_priv;
|
||||
struct dvb_frontend *fe = &v4l2_fe->v4l2_ad->fe;
|
||||
struct dvb_frontend *fe = &v4l2_fe->fe;
|
||||
|
||||
pr_dbg("%s.\n", __func__);
|
||||
|
||||
@@ -949,7 +981,7 @@ static int v4l2_set_frontend(struct v4l2_frontend *v4l2_fe,
|
||||
|
||||
/* Request the search algorithm to search */
|
||||
fepriv->algo_status |= V4L2_SEARCH_AGAIN;
|
||||
if (params->flag) {
|
||||
if (params->flag & ANALOG_FLAG_ENABLE_AFC) {
|
||||
/*dvb_frontend_add_event(fe, 0); */
|
||||
v4l2_frontend_clear_events(v4l2_fe);
|
||||
v4l2_frontend_wakeup(v4l2_fe);
|
||||
@@ -988,7 +1020,7 @@ static int v4l2_frontend_set_mode(struct v4l2_frontend *v4l2_fe,
|
||||
|
||||
fepriv->state = V4L2FE_STATE_IDLE;
|
||||
|
||||
analog_ops = &v4l2_fe->v4l2_ad->fe.ops.analog_ops;
|
||||
analog_ops = &v4l2_fe->fe.ops.analog_ops;
|
||||
|
||||
if (params)
|
||||
priv_cfg = AML_ATVDEMOD_INIT;
|
||||
@@ -996,7 +1028,7 @@ static int v4l2_frontend_set_mode(struct v4l2_frontend *v4l2_fe,
|
||||
priv_cfg = AML_ATVDEMOD_UNINIT;
|
||||
|
||||
if (analog_ops && analog_ops->set_config)
|
||||
ret = analog_ops->set_config(&v4l2_fe->v4l2_ad->fe, &priv_cfg);
|
||||
ret = analog_ops->set_config(&v4l2_fe->fe, &priv_cfg);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1008,16 +1040,16 @@ static int v4l2_frontend_read_status(struct v4l2_frontend *v4l2_fe,
|
||||
struct analog_demod_ops *analog_ops = NULL;
|
||||
struct dvb_tuner_ops *tuner_ops = NULL;
|
||||
|
||||
analog_ops = &v4l2_fe->v4l2_ad->fe.ops.analog_ops;
|
||||
tuner_ops = &v4l2_fe->v4l2_ad->fe.ops.tuner_ops;
|
||||
analog_ops = &v4l2_fe->fe.ops.analog_ops;
|
||||
tuner_ops = &v4l2_fe->fe.ops.tuner_ops;
|
||||
|
||||
if (!status)
|
||||
return -1;
|
||||
#if 0
|
||||
if (analog_ops->tuner_status)
|
||||
analog_ops->tuner_status(&v4l2_fe->v4l2_ad->fe, status);
|
||||
analog_ops->tuner_status(&v4l2_fe->fe, status);
|
||||
else if (tuner_ops->get_status)
|
||||
tuner_ops->get_status(&v4l2_fe->v4l2_ad->fe, status);
|
||||
tuner_ops->get_status(&v4l2_fe->fe, status);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
@@ -1121,30 +1153,16 @@ static long v4l2_frontend_ioctl(struct file *filp, void *fh, bool valid_prio,
|
||||
static int v4l2_frontend_open(struct file *filp)
|
||||
{
|
||||
int ret = 0;
|
||||
void *p = NULL;
|
||||
struct v4l2_frontend *v4l2_fe = video_get_drvdata(video_devdata(filp));
|
||||
struct v4l2_frontend_private *fepriv = v4l2_fe->frontend_priv;
|
||||
struct dvb_tuner_ops *tuner_ops = &v4l2_fe->v4l2_ad->fe.ops.tuner_ops;
|
||||
|
||||
if (tuner_ops->init == NULL) {
|
||||
switch (v4l2_fe->v4l2_ad->tuner_id) {
|
||||
case AM_TUNER_R840:
|
||||
break;
|
||||
case AM_TUNER_SI2151:
|
||||
p = v4l2_attach(si2151_attach, &v4l2_fe->v4l2_ad->fe,
|
||||
v4l2_fe->v4l2_ad->i2c.adapter,
|
||||
v4l2_fe->v4l2_ad->i2c.addr);
|
||||
break;
|
||||
case AM_TUNER_MXL661:
|
||||
p = v4l2_attach(mxl661_attach, &v4l2_fe->v4l2_ad->fe,
|
||||
v4l2_fe->v4l2_ad->i2c.adapter,
|
||||
v4l2_fe->v4l2_ad->i2c.addr);
|
||||
break;
|
||||
}
|
||||
|
||||
if (p == NULL) {
|
||||
pr_err("%s: v4l2_attach tuner %d error.\n",
|
||||
__func__, v4l2_fe->v4l2_ad->tuner_id);
|
||||
/* Because tuner ko insmod after demod, so need check */
|
||||
if (!amlatvdemod_devp->tuner_attached
|
||||
|| !amlatvdemod_devp->analog_attached) {
|
||||
ret = aml_attach_demod_tuner(amlatvdemod_devp);
|
||||
if (ret < 0) {
|
||||
pr_err("%s: attach demod or tuner %d error.\n",
|
||||
__func__, v4l2_fe->tuner_id);
|
||||
return -EBUSY;
|
||||
}
|
||||
}
|
||||
@@ -1275,15 +1293,14 @@ static struct video_device aml_atvdemod_vdev = {
|
||||
.vfl_dir = VFL_DIR_TX,
|
||||
};
|
||||
|
||||
int v4l2_resister_frontend(struct v4l2_adapter *v4l2_ad,
|
||||
struct v4l2_frontend *v4l2_fe)
|
||||
int v4l2_resister_frontend(struct v4l2_frontend *v4l2_fe)
|
||||
{
|
||||
int ret = 0;
|
||||
struct v4l2_frontend_private *fepriv = NULL;
|
||||
struct v4l2_atvdemod_device *v4l2dev = NULL;
|
||||
|
||||
if (!v4l2_ad || !v4l2_fe) {
|
||||
pr_err("NULL pointer.\n");
|
||||
if (!v4l2_fe) {
|
||||
pr_err("v4l2_fe NULL pointer.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1299,7 +1316,6 @@ int v4l2_resister_frontend(struct v4l2_adapter *v4l2_ad,
|
||||
}
|
||||
|
||||
v4l2_fe->search = v4l2_frontend_search;
|
||||
v4l2_fe->v4l2_ad = v4l2_ad;
|
||||
fepriv = v4l2_fe->frontend_priv;
|
||||
|
||||
fepriv->v4l2dev = kzalloc(sizeof(struct v4l2_atvdemod_device),
|
||||
@@ -1311,7 +1327,7 @@ int v4l2_resister_frontend(struct v4l2_adapter *v4l2_ad,
|
||||
|
||||
v4l2dev = fepriv->v4l2dev;
|
||||
v4l2dev->name = DEVICE_NAME;
|
||||
v4l2dev->dev = v4l2_fe->v4l2_ad->dev;
|
||||
v4l2dev->dev = v4l2_fe->dev;
|
||||
|
||||
snprintf(v4l2dev->v4l2_dev.name, sizeof(v4l2dev->v4l2_dev.name),
|
||||
"%s", DEVICE_NAME);
|
||||
@@ -1335,12 +1351,6 @@ int v4l2_resister_frontend(struct v4l2_adapter *v4l2_ad,
|
||||
goto vdev_fail;
|
||||
}
|
||||
|
||||
if (!aml_atvdemod_attach(&v4l2_ad->fe, v4l2_ad->i2c.adapter,
|
||||
v4l2_ad->i2c.addr, v4l2_ad->tuner_id)) {
|
||||
pr_err("atvdemod attach fail.\n");
|
||||
goto attach_fail;
|
||||
}
|
||||
|
||||
sema_init(&fepriv->sem, 1);
|
||||
init_waitqueue_head(&fepriv->wait_queue);
|
||||
init_waitqueue_head(&fepriv->events.wait_queue);
|
||||
@@ -1352,8 +1362,6 @@ int v4l2_resister_frontend(struct v4l2_adapter *v4l2_ad,
|
||||
|
||||
return 0;
|
||||
|
||||
attach_fail:
|
||||
|
||||
vdev_fail:
|
||||
v4l2_device_unregister(&v4l2dev->v4l2_dev);
|
||||
|
||||
@@ -1387,7 +1395,7 @@ int v4l2_unresister_frontend(struct v4l2_frontend *v4l2_fe)
|
||||
int v4l2_frontend_suspend(struct v4l2_frontend *v4l2_fe)
|
||||
{
|
||||
int ret = 0;
|
||||
struct dvb_frontend *fe = &v4l2_fe->v4l2_ad->fe;
|
||||
struct dvb_frontend *fe = &v4l2_fe->fe;
|
||||
struct dvb_tuner_ops tuner_ops = fe->ops.tuner_ops;
|
||||
struct analog_demod_ops analog_ops = fe->ops.analog_ops;
|
||||
|
||||
@@ -1406,7 +1414,7 @@ int v4l2_frontend_resume(struct v4l2_frontend *v4l2_fe)
|
||||
{
|
||||
int ret = 0;
|
||||
struct v4l2_frontend_private *fepriv = v4l2_fe->frontend_priv;
|
||||
struct dvb_frontend *fe = &v4l2_fe->v4l2_ad->fe;
|
||||
struct dvb_frontend *fe = &v4l2_fe->fe;
|
||||
struct dvb_tuner_ops tuner_ops = fe->ops.tuner_ops;
|
||||
struct analog_demod_ops analog_ops = fe->ops.analog_ops;
|
||||
int priv_cfg = AML_ATVDEMOD_RESUME;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#ifndef __ATV_DEMOD_V4L2_H__
|
||||
#define __ATV_DEMOD_V4L2_H__
|
||||
|
||||
#include <linux/amlogic/aml_atvdemod.h>
|
||||
#include <media/v4l2-device.h>
|
||||
#include "drivers/media/dvb-core/dvb_frontend.h"
|
||||
|
||||
@@ -69,10 +70,10 @@
|
||||
#define V4L2_SET_MODE _IO('V', 108)
|
||||
#define V4L2_READ_STATUS _IOR('V', 109, enum v4l2_status)
|
||||
|
||||
/*COLOR MODULATION TYPE*/
|
||||
#define V4L2_COLOR_STD_PAL ((v4l2_std_id) 0x04000000)
|
||||
#define V4L2_COLOR_STD_NTSC ((v4l2_std_id) 0x08000000)
|
||||
#define V4L2_COLOR_STD_SECAM ((v4l2_std_id) 0x10000000)
|
||||
|
||||
#define ANALOG_FLAG_ENABLE_AFC 0X00000001
|
||||
#define ANALOG_FLAG_MANUL_SCAN 0x00000011
|
||||
|
||||
|
||||
struct v4l2_analog_parameters {
|
||||
unsigned int frequency;
|
||||
@@ -148,7 +149,11 @@ struct v4l2_adapter {
|
||||
};
|
||||
|
||||
struct v4l2_frontend {
|
||||
struct v4l2_adapter *v4l2_ad;
|
||||
struct device *dev;
|
||||
|
||||
struct dvb_frontend fe;
|
||||
unsigned int tuner_id;
|
||||
struct i2c_client i2c;
|
||||
|
||||
void *frontend_priv;
|
||||
void *tuner_priv;
|
||||
@@ -175,8 +180,7 @@ struct v4l2_atvdemod_device {
|
||||
enum v4l2_search (*search)(struct v4l2_atvdemod_device *dev);
|
||||
};
|
||||
|
||||
int v4l2_resister_frontend(struct v4l2_adapter *v4l2_ad,
|
||||
struct v4l2_frontend *v4l2_fe);
|
||||
int v4l2_resister_frontend(struct v4l2_frontend *v4l2_fe);
|
||||
int v4l2_unresister_frontend(struct v4l2_frontend *v4l2_fe);
|
||||
|
||||
int v4l2_frontend_suspend(struct v4l2_frontend *v4l2_fe);
|
||||
|
||||
@@ -34,6 +34,19 @@ static unsigned int audio_thd_threshold2 = 0xf00;
|
||||
module_param(audio_thd_threshold2, uint, 0644);
|
||||
MODULE_PARM_DESC(audio_thd_threshold2, "\n audio_thd_threshold2\n");
|
||||
|
||||
#undef pr_info
|
||||
#define pr_info(args...)\
|
||||
do {\
|
||||
if (ademod_debug_en)\
|
||||
printk(args);\
|
||||
} while (0)
|
||||
#undef pr_dbg
|
||||
#define pr_dbg(a...) \
|
||||
do {\
|
||||
if (1)\
|
||||
printk(a);\
|
||||
} while (0)
|
||||
|
||||
int deem_75u_30[7] = {10, 6, 0, -971, 0, -44, 97};
|
||||
int deem_75u_40[7] = {10, 6, 0, -971, 0, -26, 80};
|
||||
int deem_75u_50[7] = {10, 6, 0, -971, 0, -16, 69};
|
||||
|
||||
@@ -1820,55 +1820,65 @@ void atvdemod_uninit(void)
|
||||
void atv_dmd_set_std(void)
|
||||
{
|
||||
v4l2_std_id ptstd = amlatvdemod_devp->std;
|
||||
|
||||
/* set broad standard of tuner*/
|
||||
if ((ptstd & V4L2_STD_B) || (ptstd & V4L2_STD_G)) {
|
||||
/* V4L2_STD_PAL_B | V4L2_STD_PAL_B1 | V4L2_STD_SECAM_B
|
||||
* | V4L2_STD_PAL_G | V4L2_STD_SECAM_G
|
||||
*/
|
||||
if ((ptstd & V4L2_COLOR_STD_PAL) && ((ptstd & V4L2_STD_B) ||
|
||||
(ptstd & V4L2_STD_G))) {
|
||||
amlatvdemod_devp->fre_offset = 2250000;
|
||||
freq_hz_cvrt = AML_ATV_DEMOD_FREQ_50HZ_VERT;
|
||||
broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_BG;
|
||||
if_freq = 3250000;
|
||||
gde_curve = 2;
|
||||
} else if (ptstd & V4L2_STD_DK) {
|
||||
/* V4L2_STD_PAL_D | V4L2_STD_PAL_K |
|
||||
* V4L2_STD_SECAM_D | V4L2_STD_SECAM_K
|
||||
*/
|
||||
} else if ((ptstd & V4L2_COLOR_STD_PAL) && (ptstd & V4L2_STD_DK)) {
|
||||
amlatvdemod_devp->fre_offset = 2250000;
|
||||
freq_hz_cvrt = AML_ATV_DEMOD_FREQ_50HZ_VERT;
|
||||
if_freq = 3250000;
|
||||
broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_DK;
|
||||
gde_curve = 3;
|
||||
} else if (ptstd & V4L2_STD_PAL_M) {
|
||||
/* V4L2_STD_PAL_M */
|
||||
} else if ((ptstd & V4L2_COLOR_STD_PAL) && (ptstd & V4L2_STD_PAL_M)) {
|
||||
amlatvdemod_devp->fre_offset = 2250000;
|
||||
freq_hz_cvrt = AML_ATV_DEMOD_FREQ_60HZ_VERT;
|
||||
broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_M;
|
||||
if_freq = 4250000;
|
||||
gde_curve = 0;
|
||||
} else if (ptstd & V4L2_STD_NTSC_M) {
|
||||
/* V4L2_STD_NTSC_M */
|
||||
} else if ((ptstd & V4L2_COLOR_STD_NTSC) && (ptstd & V4L2_STD_NTSC_M)) {
|
||||
amlatvdemod_devp->fre_offset = 1750000;
|
||||
freq_hz_cvrt = AML_ATV_DEMOD_FREQ_60HZ_VERT;
|
||||
if_freq = 4250000;
|
||||
broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC;
|
||||
gde_curve = 0;
|
||||
} else if (ptstd & V4L2_STD_NTSC_M_JP) {
|
||||
/* V4L2_STD_NTSC_M_JP */
|
||||
} else if ((ptstd & V4L2_COLOR_STD_NTSC) && (ptstd & V4L2_STD_DK)) {
|
||||
amlatvdemod_devp->fre_offset = 1750000;
|
||||
freq_hz_cvrt = AML_ATV_DEMOD_FREQ_60HZ_VERT;
|
||||
if_freq = 4250000;
|
||||
broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_DK;
|
||||
gde_curve = 0;
|
||||
} else if ((ptstd & V4L2_COLOR_STD_NTSC) && (ptstd & V4L2_STD_BG)) {
|
||||
amlatvdemod_devp->fre_offset = 1750000;
|
||||
freq_hz_cvrt = AML_ATV_DEMOD_FREQ_60HZ_VERT;
|
||||
if_freq = 4250000;
|
||||
broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_BG;
|
||||
gde_curve = 0;
|
||||
} else if ((ptstd & V4L2_COLOR_STD_NTSC) && (ptstd & V4L2_STD_PAL_I)) {
|
||||
amlatvdemod_devp->fre_offset = 1750000;
|
||||
freq_hz_cvrt = AML_ATV_DEMOD_FREQ_60HZ_VERT;
|
||||
if_freq = 4250000;
|
||||
broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_I;
|
||||
gde_curve = 0;
|
||||
} else if ((ptstd & V4L2_COLOR_STD_NTSC) &&
|
||||
(ptstd & V4L2_STD_NTSC_M_JP)) {
|
||||
amlatvdemod_devp->fre_offset = 1750000;
|
||||
freq_hz_cvrt = AML_ATV_DEMOD_FREQ_50HZ_VERT;
|
||||
broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_J;
|
||||
if_freq = 4250000;
|
||||
gde_curve = 0;
|
||||
} else if (ptstd & V4L2_STD_PAL_I) {
|
||||
/* V4L2_STD_PAL_I */
|
||||
} else if ((ptstd & V4L2_COLOR_STD_PAL) && (ptstd & V4L2_STD_PAL_I)) {
|
||||
amlatvdemod_devp->fre_offset = 2750000;
|
||||
freq_hz_cvrt = AML_ATV_DEMOD_FREQ_50HZ_VERT;
|
||||
broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_I;
|
||||
if_freq = 3250000;
|
||||
gde_curve = 4;
|
||||
} else if (ptstd & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC)) {
|
||||
/* V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC */
|
||||
amlatvdemod_devp->fre_offset = 2750000;
|
||||
freq_hz_cvrt = AML_ATV_DEMOD_FREQ_50HZ_VERT;
|
||||
broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_SECAM_L;
|
||||
@@ -1884,13 +1894,16 @@ void atv_dmd_set_std(void)
|
||||
} else if (amlatvdemod_devp->tuner_id == AM_TUNER_SI2151) {
|
||||
if_freq = amlatvdemod_devp->if_freq;
|
||||
if_inv = amlatvdemod_devp->if_inv;
|
||||
} else if (amlatvdemod_devp->tuner_id == AM_TUNER_SI2159) {
|
||||
if_freq = amlatvdemod_devp->if_freq;
|
||||
if_inv = amlatvdemod_devp->if_inv;
|
||||
}
|
||||
|
||||
pr_info("[atvdemod]%s:broad_std %d,freq_hz_cvrt:0x%x,fre_offset:%d.\n",
|
||||
pr_info("[%s] broad_std:%d, freq_hz_cvrt:0x%x, fre_offset:%d.\n",
|
||||
__func__, broad_std, freq_hz_cvrt,
|
||||
amlatvdemod_devp->fre_offset);
|
||||
if (atvdemod_init())
|
||||
pr_info("[atvdemod..]%s: atv restart error.\n", __func__);
|
||||
pr_info("[%s]: atv restart error.\n", __func__);
|
||||
}
|
||||
|
||||
int aml_audiomode_autodet(struct dvb_frontend *fe)
|
||||
@@ -2027,26 +2040,26 @@ int aml_audiomode_autodet(struct dvb_frontend *fe)
|
||||
}
|
||||
}
|
||||
if (priv != NULL) {
|
||||
param->param.std = V4L2_STD_PAL;
|
||||
param->param.std = V4L2_COLOR_STD_PAL;
|
||||
switch (broad_std) {
|
||||
case AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_DK:
|
||||
param->param.std = V4L2_STD_PAL_DK;
|
||||
param->param.std |= V4L2_STD_PAL_DK;
|
||||
param->param.audmode = V4L2_STD_PAL_DK;
|
||||
break;
|
||||
case AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_I:
|
||||
param->param.std = V4L2_STD_PAL_I;
|
||||
param->param.std |= V4L2_STD_PAL_I;
|
||||
param->param.audmode = V4L2_STD_PAL_I;
|
||||
break;
|
||||
case AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_BG:
|
||||
param->param.std = V4L2_STD_PAL_BG;
|
||||
param->param.std |= V4L2_STD_PAL_BG;
|
||||
param->param.audmode = V4L2_STD_PAL_BG;
|
||||
break;
|
||||
case AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_M:
|
||||
param->param.std = V4L2_STD_PAL_M;
|
||||
param->param.std |= V4L2_STD_PAL_M;
|
||||
param->param.audmode = V4L2_STD_PAL_M;
|
||||
break;
|
||||
default:
|
||||
param->param.std = V4L2_STD_PAL_DK;
|
||||
param->param.std |= V4L2_STD_PAL_DK;
|
||||
param->param.audmode = V4L2_STD_PAL_DK;
|
||||
}
|
||||
param->param.frequency += 1;
|
||||
@@ -2060,7 +2073,8 @@ int aml_audiomode_autodet(struct dvb_frontend *fe)
|
||||
broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_I;
|
||||
cur_std = ID_PAL_I;
|
||||
if (priv != NULL) {
|
||||
param->param.std = V4L2_STD_PAL_I;
|
||||
param->param.std = V4L2_COLOR_STD_PAL
|
||||
| V4L2_STD_PAL_I;
|
||||
param->param.frequency += 1;
|
||||
param->param.audmode = V4L2_STD_PAL_I;
|
||||
}
|
||||
@@ -2070,7 +2084,8 @@ int aml_audiomode_autodet(struct dvb_frontend *fe)
|
||||
broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_BG;
|
||||
cur_std = ID_PAL_BG;
|
||||
if (priv != NULL) {
|
||||
param->param.std = V4L2_STD_PAL_BG;
|
||||
param->param.std = V4L2_COLOR_STD_PAL
|
||||
| V4L2_STD_PAL_BG;
|
||||
param->param.frequency += 1;
|
||||
param->param.audmode = V4L2_STD_PAL_BG;
|
||||
}
|
||||
@@ -2080,7 +2095,8 @@ int aml_audiomode_autodet(struct dvb_frontend *fe)
|
||||
broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_M;
|
||||
cur_std = ID_PAL_M;
|
||||
if (priv != NULL) {
|
||||
param->param.std = V4L2_STD_PAL_M;
|
||||
param->param.std = V4L2_COLOR_STD_PAL
|
||||
| V4L2_STD_PAL_M;
|
||||
param->param.frequency += 1;
|
||||
param->param.audmode = V4L2_STD_PAL_M;
|
||||
}
|
||||
@@ -2090,7 +2106,8 @@ int aml_audiomode_autodet(struct dvb_frontend *fe)
|
||||
broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_DK;
|
||||
cur_std = ID_PAL_DK;
|
||||
if (priv != NULL) {
|
||||
param->param.std = V4L2_STD_PAL_DK;
|
||||
param->param.std = V4L2_COLOR_STD_PAL
|
||||
| V4L2_STD_PAL_DK;
|
||||
param->param.frequency += 1;
|
||||
param->param.audmode = V4L2_STD_PAL_DK;
|
||||
}
|
||||
@@ -2135,8 +2152,8 @@ int aml_audiomode_autodet(struct dvb_frontend *fe)
|
||||
}
|
||||
carrier_power = carrier_power_max/i;
|
||||
carrier_power_max = 0;
|
||||
pr_err("[amlatvdemod.. %d,std:%d ]%s: atvdemo audio carrier power report:%lu. @@@@@@@@@@\n",
|
||||
num, broad_std, __func__, carrier_power);
|
||||
pr_err("[%s] [num:%d] [broad_std:%d] audio carrier power: %lu. @@@@@@@@@@\n",
|
||||
__func__, num, broad_std, carrier_power);
|
||||
carrier_power_average[cur_std] += carrier_power;
|
||||
num++;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,134 @@
|
||||
#ifndef __AML_ATVDEMOD_H__
|
||||
#define __AML_ATVDEMOD_H__
|
||||
|
||||
#include <linux/i2c.h>
|
||||
#include <uapi/linux/videodev2.h>
|
||||
|
||||
/*COLOR MODULATION TYPE*/
|
||||
#define V4L2_COLOR_STD_PAL ((v4l2_std_id) 0x04000000)
|
||||
#define V4L2_COLOR_STD_NTSC ((v4l2_std_id) 0x08000000)
|
||||
#define V4L2_COLOR_STD_SECAM ((v4l2_std_id) 0x10000000)
|
||||
|
||||
/* For convert v4l2 std define to string */
|
||||
static inline const char *v4l2_std_to_str(v4l2_std_id std)
|
||||
{
|
||||
switch (std) {
|
||||
case V4L2_STD_PAL_B:
|
||||
return "V4L2_STD_PAL_B";
|
||||
case V4L2_STD_PAL_B1:
|
||||
return "V4L2_STD_PAL_B1";
|
||||
case V4L2_STD_PAL_G:
|
||||
return "V4L2_STD_PAL_G";
|
||||
case V4L2_STD_PAL_H:
|
||||
return "V4L2_STD_PAL_H";
|
||||
case V4L2_STD_PAL_I:
|
||||
return "V4L2_STD_PAL_I";
|
||||
case V4L2_STD_PAL_D:
|
||||
return "V4L2_STD_PAL_D";
|
||||
case V4L2_STD_PAL_D1:
|
||||
return "V4L2_STD_PAL_D1";
|
||||
case V4L2_STD_PAL_K:
|
||||
return "V4L2_STD_PAL_K";
|
||||
case V4L2_STD_PAL_M:
|
||||
return "V4L2_STD_PAL_M";
|
||||
case V4L2_STD_PAL_N:
|
||||
return "V4L2_STD_PAL_N";
|
||||
case V4L2_STD_PAL_Nc:
|
||||
return "V4L2_STD_PAL_Nc";
|
||||
case V4L2_STD_PAL_60:
|
||||
return "V4L2_STD_PAL_60";
|
||||
case V4L2_STD_NTSC_M:
|
||||
return "V4L2_STD_NTSC_M";
|
||||
case V4L2_STD_NTSC_M_JP:
|
||||
return "V4L2_STD_NTSC_M_JP";
|
||||
case V4L2_STD_NTSC_443:
|
||||
return "V4L2_STD_NTSC_443";
|
||||
case V4L2_STD_NTSC_M_KR:
|
||||
return "V4L2_STD_NTSC_M_KR";
|
||||
case V4L2_STD_SECAM_B:
|
||||
return "V4L2_STD_SECAM_B";
|
||||
case V4L2_STD_SECAM_D:
|
||||
return "V4L2_STD_SECAM_D";
|
||||
case V4L2_STD_SECAM_G:
|
||||
return "V4L2_STD_SECAM_G";
|
||||
case V4L2_STD_SECAM_H:
|
||||
return "V4L2_STD_SECAM_H";
|
||||
case V4L2_STD_SECAM_K:
|
||||
return "V4L2_STD_SECAM_K";
|
||||
case V4L2_STD_SECAM_K1:
|
||||
return "V4L2_STD_SECAM_K1";
|
||||
case V4L2_STD_SECAM_L:
|
||||
return "V4L2_STD_SECAM_L";
|
||||
case V4L2_STD_SECAM_LC:
|
||||
return "V4L2_STD_SECAM_LC";
|
||||
case V4L2_STD_ATSC_8_VSB:
|
||||
return "V4L2_STD_ATSC_8_VSB";
|
||||
case V4L2_STD_ATSC_16_VSB:
|
||||
return "V4L2_STD_ATSC_16_VSB";
|
||||
case V4L2_COLOR_STD_PAL:
|
||||
return "V4L2_COLOR_STD_PAL";
|
||||
case V4L2_COLOR_STD_NTSC:
|
||||
return "V4L2_COLOR_STD_NTSC";
|
||||
case V4L2_COLOR_STD_SECAM:
|
||||
return "V4L2_COLOR_STD_SECAM";
|
||||
case V4L2_STD_MN:
|
||||
return "V4L2_STD_MN";
|
||||
case V4L2_STD_B:
|
||||
return "V4L2_STD_B";
|
||||
case V4L2_STD_GH:
|
||||
return "V4L2_STD_GH";
|
||||
case V4L2_STD_DK:
|
||||
return "V4L2_STD_DK";
|
||||
case V4L2_STD_PAL_BG:
|
||||
return "V4L2_STD_PAL_BG";
|
||||
case V4L2_STD_PAL_DK:
|
||||
return "V4L2_STD_PAL_DK";
|
||||
case V4L2_STD_PAL:
|
||||
return "V4L2_STD_PAL";
|
||||
case V4L2_STD_NTSC:
|
||||
return "V4L2_STD_NTSC";
|
||||
case V4L2_STD_SECAM_DK:
|
||||
return "V4L2_STD_SECAM_DK";
|
||||
case V4L2_STD_SECAM:
|
||||
return "V4L2_STD_SECAM";
|
||||
case V4L2_STD_525_60:
|
||||
return "V4L2_STD_525_60";
|
||||
case V4L2_STD_625_50:
|
||||
return "V4L2_STD_625_50";
|
||||
case V4L2_STD_ATSC:
|
||||
return "V4L2_STD_ATSC";
|
||||
case V4L2_STD_ALL:
|
||||
return "V4L2_STD_ALL";
|
||||
default:
|
||||
return "V4L2_STD_UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
/* For audio driver get atv audio state */
|
||||
extern void aml_fe_get_atvaudio_state(int *state);
|
||||
|
||||
/* For attach tuner driver start*/
|
||||
enum aml_tuner_type_t {
|
||||
AM_TUNER_SI2176 = 1,
|
||||
AM_TUNER_SI2196 = 2,
|
||||
AM_TUNER_FQ1216 = 3,
|
||||
AM_TUNER_HTM = 4,
|
||||
AM_TUNER_CTC703 = 5,
|
||||
AM_TUNER_SI2177 = 6,
|
||||
AM_TUNER_R840 = 7,
|
||||
AM_TUNER_SI2157 = 8,
|
||||
AM_TUNER_SI2151 = 9,
|
||||
AM_TUNER_MXL661 = 10,
|
||||
AM_TUNER_MXL608 = 11,
|
||||
AM_TUNER_SI2159 = 12,
|
||||
};
|
||||
|
||||
extern struct dvb_frontend *mxl661_attach(struct dvb_frontend *fe,
|
||||
struct i2c_adapter *i2c_adap, u8 i2c_addr);
|
||||
extern struct dvb_frontend *si2151_attach(struct dvb_frontend *fe,
|
||||
struct i2c_adapter *i2c_adap, u8 i2c_addr);
|
||||
extern struct dvb_frontend *si2159_attach(struct dvb_frontend *fe,
|
||||
struct i2c_adapter *i2c_adap, u8 i2c_addr);
|
||||
/* For attach tuner driver end*/
|
||||
|
||||
#endif /* __AML_ATVDEMOD_H__ */
|
||||
|
||||
Reference in New Issue
Block a user