atv_demod: modify atv demod code [1/1]

PD#SWPL-2295

Problem:
1.modify atv demod code for coverity.
2.add ntsc-m ring filter for t962x2.
3.merge code optimization from android l.
4.add tuner compatible info in dts for tuner debug.

Solution:
1.modify atv demod code for coverity.
2.add ntsc-m ring filter for t962x2.
3.merge code optimization from android l.
4.add tuner compatible info in dts for tuner debug.

Verify:
verified by einstein

Change-Id: I9696aa628315ee11f0c9dd279c7cc03797f04331
Signed-off-by: nengwen.chen <nengwen.chen@amlogic.com>
This commit is contained in:
nengwen.chen
2018-12-05 13:37:41 +08:00
committed by Jianxin Pan
parent f8afa29500
commit ff129142f6
35 changed files with 208 additions and 91 deletions

View File

@@ -614,6 +614,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "mxl661_tuner";
tuner_i2c_adap = <&i2c0>;

View File

@@ -1094,6 +1094,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "mxl661_tuner";
tuner_i2c_adap = <&i2c0>;

View File

@@ -1100,6 +1100,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "mxl661_tuner";
tuner_i2c_adap = <&i2c0>;

View File

@@ -436,6 +436,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "r842_tuner";
tuner_i2c_adap = <&i2c1>;

View File

@@ -437,6 +437,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "r842_tuner";
tuner_i2c_adap = <&i2c1>;

View File

@@ -427,6 +427,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "si2151_tuner";
tuner_i2c_adap = <&i2c1>;

View File

@@ -432,6 +432,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "r842_tuner";
tuner_i2c_adap = <&i2c1>;

View File

@@ -432,6 +432,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "r842_tuner";
tuner_i2c_adap = <&i2c1>;

View File

@@ -626,6 +626,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "si2151_tuner";
tuner_i2c_adap = <&i2c1>;

View File

@@ -670,6 +670,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "si2151_tuner";
tuner_i2c_adap = <&i2c1>;

View File

@@ -632,6 +632,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "mxl661_tuner";
tuner_i2c_adap = <&i2c1>;

View File

@@ -629,6 +629,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "mxl661_tuner";
tuner_i2c_adap = <&i2c1>;

View File

@@ -625,6 +625,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "mxl661_tuner";
tuner_i2c_adap = <&i2c1>;

View File

@@ -632,6 +632,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "mxl661_tuner";
tuner_i2c_adap = <&i2c1>;

View File

@@ -436,6 +436,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "r842_tuner";
tuner_i2c_adap = <&i2c1>;

View File

@@ -436,6 +436,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "r842_tuner";
tuner_i2c_adap = <&i2c1>;

View File

@@ -427,6 +427,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "si2151_tuner";
tuner_i2c_adap = <&i2c1>;

View File

@@ -424,6 +424,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "r842_tuner";
tuner_i2c_adap = <&i2c1>;

View File

@@ -424,6 +424,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "r842_tuner";
tuner_i2c_adap = <&i2c1>;

View File

@@ -625,6 +625,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "si2151_tuner";
tuner_i2c_adap = <&i2c1>;

View File

@@ -669,6 +669,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "si2151_tuner";
tuner_i2c_adap = <&i2c1>;

View File

@@ -626,6 +626,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "mxl661_tuner";
tuner_i2c_adap = <&i2c1>;

View File

@@ -626,6 +626,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "mxl661_tuner";
tuner_i2c_adap = <&i2c1>;

View File

@@ -625,6 +625,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "mxl661_tuner";
tuner_i2c_adap = <&i2c1>;

View File

@@ -627,6 +627,7 @@
};
tuner: tuner {
compatible = "amlogic, tuner";
status = "okay";
tuner_name = "mxl661_tuner";
tuner_i2c_adap = <&i2c1>;

View File

@@ -102,8 +102,8 @@ int atvaudiodem_reg_read(unsigned int reg, unsigned int *val)
}
}
#endif
if (amlatvdemod_devp->audio_reg_base)
*val = readl(amlatvdemod_devp->audio_reg_base + reg);
if (amlatvdemod_devp->audiodemod_reg_base)
*val = readl(amlatvdemod_devp->audiodemod_reg_base + reg);
return 0;
}
@@ -128,8 +128,32 @@ int atvaudiodem_reg_write(unsigned int reg, unsigned int val)
}
#endif
if (amlatvdemod_devp->audiodemod_reg_base)
writel(val, (amlatvdemod_devp->audiodemod_reg_base + reg));
return 0;
}
int atvaudio_reg_read(unsigned int *val)
{
/* only 0xffd0d340 read */
/* bit0: I2s select in_src, 0 = atv_demod, 1 = adec */
/* bit1: Din5, 0 = atv_demod, 1 = adec */
/* bit2: L/R swap for adec audio data */
if (amlatvdemod_devp->audio_reg_base)
writel(val, (amlatvdemod_devp->audio_reg_base + reg));
*val = readl(amlatvdemod_devp->audio_reg_base);
return 0;
}
int atvaudio_reg_write(unsigned int val)
{
/* only 0xffd0d340 write */
/* bit0: I2s select in_src, 0 = atv_demod, 1 = adec */
/* bit1: Din5, 0 = atv_demod, 1 = adec */
/* bit2: L/R swap for adec audio data */
if (amlatvdemod_devp->audio_reg_base)
writel(val, amlatvdemod_devp->audio_reg_base);
return 0;
}
@@ -179,10 +203,10 @@ void atv_dmd_wr_reg(unsigned char block, unsigned char reg, unsigned long data)
unsigned long atv_dmd_rd_reg(unsigned char block, unsigned char reg)
{
unsigned long data = 0;
unsigned int data = 0;
unsigned int reg_addr = (block << 8) + reg * 4;
amlatvdemod_reg_read(reg_addr, (unsigned int *)&data);
amlatvdemod_reg_read(reg_addr, &data);
return data;
}

View File

@@ -25,6 +25,8 @@ extern int amlatvdemod_reg_read(unsigned int reg, unsigned int *val);
extern int amlatvdemod_reg_write(unsigned int reg, unsigned int val);
extern int atvaudiodem_reg_read(unsigned int reg, unsigned int *val);
extern int atvaudiodem_reg_write(unsigned int reg, unsigned int val);
extern int atvaudio_reg_read(unsigned int *val);
extern int atvaudio_reg_write(unsigned int val);
extern int amlatvdemod_hiu_reg_read(unsigned int reg, unsigned int *val);
extern int amlatvdemod_hiu_reg_write(unsigned int reg, unsigned int val);
extern int amlatvdemod_periphs_reg_read(unsigned int reg, unsigned int *val);

View File

@@ -94,6 +94,8 @@
DEBUGFS_CREATE_NODE(audio_a2_power_threshold, 0640, dentry, u32)\
DEBUGFS_CREATE_NODE(audio_gain_shift, 0640, dentry, u32)\
DEBUGFS_CREATE_NODE(audio_gain_lpr, 0640, dentry, u32)\
DEBUGFS_CREATE_NODE(audio_atv_ov, 0640, dentry, u32)\
DEBUGFS_CREATE_NODE(audio_atv_ov_flag, 0640, dentry, u32)\
}
@@ -176,12 +178,11 @@ static ssize_t debugfs_write(struct file *file, const char __user *userbuf,
char buf[20] = { 0 };
int len = ARRAY_SIZE(debugfs_dentry);
memset(buf, 0, sizeof(buf));
count = min_t(size_t, count, (sizeof(buf) - 1));
if (copy_from_user(buf, userbuf, count))
return -EFAULT;
buf[count] = 0;
/*i = sscanf(buf, "%d", &val);*/
i = kstrtoint(buf, 0, &val);
if (i == 0) {

View File

@@ -551,7 +551,7 @@ static int aml_atvdemod_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
pr_err("get demod memory resource fail.\n");
pr_err("no demod memory resource.\n");
goto fail_get_resource;
}
@@ -569,7 +569,7 @@ static int aml_atvdemod_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (!res) {
pr_err("no hiu demod memory resource.\n");
pr_err("no hiu memory resource.\n");
dev->hiu_reg_base = NULL;
} else {
size_io_reg = resource_size(res);
@@ -587,7 +587,7 @@ static int aml_atvdemod_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
if (!res) {
pr_err("no periphs demod memory resource.\n");
pr_err("no periphs memory resource.\n");
dev->periphs_reg_base = NULL;
} else {
size_io_reg = resource_size(res);
@@ -605,35 +605,31 @@ static int aml_atvdemod_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 3);
if (!res) {
pr_err("no audio demod memory resource.\n");
dev->audio_reg_base = NULL;
pr_err("no audiodemod memory resource.\n");
dev->audiodemod_reg_base = NULL;
} else {
size_io_reg = resource_size(res);
dev->audio_reg_base = devm_ioremap_nocache(
dev->audiodemod_reg_base = devm_ioremap_nocache(
&pdev->dev, res->start, size_io_reg);
if (!dev->audio_reg_base) {
pr_err("audio ioremap failed.\n");
if (!dev->audiodemod_reg_base) {
pr_err("audiodemod ioremap failed.\n");
goto fail_get_resource;
}
pr_info("audio start = 0x%p, size = 0x%x, base = 0x%p.\n",
pr_info("audiodemod start = 0x%p, size = 0x%x, base = 0x%p.\n",
(void *) res->start, size_io_reg,
dev->audio_reg_base);
dev->audiodemod_reg_base);
}
/* add for audio system control */
if (is_meson_txlx_cpu() || is_meson_txhd_cpu()) {
/* add for audio system control */
dev->audio_demod_reg_base = ioremap(
round_down(0xffd0d340, 0x3), 4);
dev->audio_reg_base = ioremap(round_down(0xffd0d340, 0x3), 4);
pr_info("audio_demod_reg_base = 0x%p.\n",
dev->audio_demod_reg_base);
pr_info("audio_reg_base = 0x%p.\n", dev->audio_reg_base);
} else if (is_meson_tl1_cpu()) {
dev->audio_demod_reg_base = ioremap(
round_down(0xff600340, 0x3), 4);
dev->audio_reg_base = ioremap(round_down(0xff600340, 0x3), 4);
pr_info("audio_demod_reg_base = 0x%p.\n",
dev->audio_demod_reg_base);
pr_info("audio_reg_base = 0x%p.\n", dev->audio_reg_base);
}
aml_atvdemod_dt_parse(dev);

View File

@@ -66,10 +66,10 @@ struct aml_atvdemod_device {
bool tuner_attached;
void __iomem *demod_reg_base;
void __iomem *audio_reg_base;
void __iomem *audiodemod_reg_base;
void __iomem *hiu_reg_base;
void __iomem *periphs_reg_base;
void __iomem *audio_demod_reg_base;
void __iomem *audio_reg_base;
unsigned int reg_23cf; /* IIR filter */
int btsc_sap_mode; /*0: off 1:monitor 2:auto */

View File

@@ -543,6 +543,7 @@ static void atvdemod_fe_try_analog_format(struct v4l2_frontend *v4l2_fe,
int i = 0;
int try_vfmt_cnt = 300;
int varify_cnt = 0;
int cvbs_std = 0;
v4l2_std_id std_bk = 0;
unsigned int broad_std = 0;
unsigned int audio = 0;
@@ -554,12 +555,12 @@ static void atvdemod_fe_try_analog_format(struct v4l2_frontend *v4l2_fe,
__func__);
break;
}
std_bk = aml_fe_hook_get_fmt();
if (std_bk) {
cvbs_std = aml_fe_hook_get_fmt();
if (cvbs_std) {
varify_cnt++;
pr_dbg("get varify_cnt:%d, cnt:%d, std_bk:0x%x\n",
pr_dbg("get cvbs_std varify_cnt:%d, cnt:%d, cvbs_std:0x%x\n",
varify_cnt, i,
(unsigned int) std_bk);
(unsigned int) cvbs_std);
if (((v4l2_fe->tuner_id == AM_TUNER_R840
|| v4l2_fe->tuner_id == AM_TUNER_R842)
&& varify_cnt > 0)
@@ -596,13 +597,13 @@ static void atvdemod_fe_try_analog_format(struct v4l2_frontend *v4l2_fe,
usleep_range(30 * 1000, 30 * 1000 + 100);
}
pr_dbg("get std_bk cnt:%d, std_bk: 0x%x\n",
i, (unsigned int) std_bk);
pr_dbg("get cvbs_std cnt:%d, cvbs_std: 0x%x\n",
i, (unsigned int) cvbs_std);
if (std_bk == 0) {
if (cvbs_std == 0) {
pr_err("%s: failed to get video fmt, assume PAL.\n",
__func__);
std_bk = TVIN_SIG_FMT_CVBS_PAL_I;
cvbs_std = TVIN_SIG_FMT_CVBS_PAL_I;
p->std = V4L2_COLOR_STD_PAL | V4L2_STD_PAL_DK;
p->frequency += 1;
p->audmode = V4L2_STD_PAL_DK;
@@ -617,7 +618,7 @@ static void atvdemod_fe_try_analog_format(struct v4l2_frontend *v4l2_fe,
usleep_range(20 * 1000, 20 * 1000 + 100);
}
std_bk = atvdemod_fe_tvin_fmt_to_v4l2_std(std_bk);
std_bk = atvdemod_fe_tvin_fmt_to_v4l2_std(cvbs_std);
} else {
/* Only search std by user setting,
* so no need tvafe identify signal.
@@ -634,9 +635,14 @@ static void atvdemod_fe_try_analog_format(struct v4l2_frontend *v4l2_fe,
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);
broad_std = aml_audiomode_autodet(v4l2_fe);
audio = atvdemod_fmt_2_v4l2_std(broad_std);
if (cvbs_std == TVIN_SIG_FMT_CVBS_NTSC_M) {
broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_M;
audio = V4L2_STD_NTSC_M;
} else {
amlatvdemod_set_std(AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC);
broad_std = aml_audiomode_autodet(v4l2_fe);
audio = atvdemod_fmt_2_v4l2_std(broad_std);
}
#if 0 /* I don't know what's going on here */
if (audio == V4L2_STD_PAL_M)
audio = V4L2_STD_NTSC_M;
@@ -656,9 +662,15 @@ static void atvdemod_fe_try_analog_format(struct v4l2_frontend *v4l2_fe,
#endif
} else {
/* V4L2_COLOR_STD_PAL */
amlatvdemod_set_std(AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_DK);
broad_std = aml_audiomode_autodet(v4l2_fe);
audio = atvdemod_fmt_2_v4l2_std(broad_std);
if (cvbs_std == TVIN_SIG_FMT_CVBS_PAL_M) {
broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_M;
audio = V4L2_STD_PAL_M;
} else {
amlatvdemod_set_std(
AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_DK);
broad_std = aml_audiomode_autodet(v4l2_fe);
audio = atvdemod_fmt_2_v4l2_std(broad_std);
}
#if 0 /* Why do this to me? We need support PAL_M.*/
if (audio == V4L2_STD_PAL_M) {
audio = atvdemod_fmt_2_v4l2_std(broad_std_except_pal_m);

View File

@@ -587,7 +587,7 @@ static int v4l2_property_process_get(struct v4l2_frontend *v4l2_fe,
return 0;
}
static int v4l2_frontend_ioctl_properties(struct file *filp,
static long v4l2_frontend_ioctl_properties(struct file *filp,
unsigned int cmd, void *parg)
{
struct v4l2_frontend *v4l2_fe = video_get_drvdata(video_devdata(filp));

View File

@@ -1355,14 +1355,10 @@ void set_output_left_right_exchange(unsigned int ch)
{
unsigned int read = 0;
if (amlatvdemod_devp->audio_demod_reg_base == NULL)
return;
read = readl(amlatvdemod_devp->audio_demod_reg_base);
atvaudio_reg_read(&read);
if ((read & (1 << 2)) != ((ch & 0x01) << 2))
writel((read & ~(1 << 2)) | ((ch & 0x01) << 2),
amlatvdemod_devp->audio_demod_reg_base);
atvaudio_reg_write((read & ~(1 << 2)) | ((ch & 0x01) << 2));
}
#endif /* __ATVAUDDEMOD_FUN_H */

View File

@@ -96,6 +96,9 @@ unsigned int audio_a2_threshold = 0x800;
unsigned int audio_a2_delay = 10;
unsigned int audio_nicam_delay = 100;
unsigned int audio_atv_ov;
unsigned int audio_atv_ov_flag;
enum AUDIO_SCAN_ID {
ID_PAL_I = 0,
ID_PAL_M,
@@ -261,6 +264,49 @@ void atv_dmd_misc(void)
carrier_amplif_val);
}
if (audio_atv_ov) {
atv_dmd_wr_long(APB_BLOCK_ADDR_SIF_STG_2,
0x14, 0x8000015);
atv_dmd_wr_long(APB_BLOCK_ADDR_SIF_STG_2,
0x18, 0x7ffff);
atv_dmd_wr_long(APB_BLOCK_ADDR_SIF_STG_2,
0x1c, 0x0f000);
atvaudio_reg_write(0x0);
audio_atv_ov_flag = 1;
} else {
atv_dmd_wr_long(APB_BLOCK_ADDR_SIF_STG_2,
0x14, 0xf400000);
atv_dmd_wr_long(APB_BLOCK_ADDR_SIF_STG_2,
0x18, 0xc000);
atv_dmd_wr_long(APB_BLOCK_ADDR_SIF_STG_2,
0x1c, 0x1f000);
atvaudio_reg_write(0x7);
audio_atv_ov_flag = 0;
}
}
void atv_dmd_ring_filter(bool on)
{
if (!is_meson_tl1_cpu())
return;
if (on) {
atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x10, 0x8274bf);
atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x14, 0x1d175c);
atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x18, 0x2aa526);
atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x1c, 0x1d175c);
atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x20, 0x2d19e4);
atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x24, 0x8274bf);
atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x28, 0x1d175c);
atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x2c, 0x2aa526);
atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x30, 0x1d175c);
atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x34, 0x2d19e4);
atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x4c, 0x1);
} else
atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x4c, 0x0);
pr_err("%s do atv_dmd_ring_filter %d ...\n", __func__, on);
}
void atv_dmd_non_std_set(bool enable)
@@ -491,7 +537,8 @@ void configure_receiver(int Broadcast_Standard, unsigned int Tuner_IF_Frequency,
(Broadcast_Standard == AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_M) ||
(Broadcast_Standard == AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_DK) ||
(Broadcast_Standard == AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_BG) ||
(Broadcast_Standard == AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_I)) {
(Broadcast_Standard == AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_I) ||
(Broadcast_Standard == AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_M)) {
gp_coeff_1[0] = 0x57777;
gp_coeff_1[1] = 0xdd777;
gp_coeff_1[2] = 0x7d777;
@@ -1748,6 +1795,12 @@ int atvdemod_init(void)
pr_err("%s do atv_dmd_misc ...\n", __func__);
atv_dmd_misc();
if (broad_std == AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_M ||
broad_std == AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC)
atv_dmd_ring_filter(true);
else
atv_dmd_ring_filter(false);
pr_err("%s do atv_dmd_soft_reset ...\n", __func__);
/*4.software reset*/
atv_dmd_soft_reset();
@@ -1894,14 +1947,14 @@ int aml_audiomode_autodet(struct v4l2_frontend *v4l2_fe)
unsigned long carrier_power_average_max = 0;
unsigned long carrier_power_average[4] = {0};
unsigned long temp_data = 0;
int carrier_lock_count = 0;
int lock = 0;
int lock = 0, line_lock = 0;
int broad_std_final = 0;
int num = 0, i = 0, final_id = 0;
int delay_ms = 10, delay_ms_default = 10;
int cur_std = ID_PAL_DK;
bool secam_signal = false;
bool ntsc_signal = false;
bool has_audio = false;
#if 0
temp_data = atv_dmd_rd_reg(APB_BLOCK_ADDR_SIF_STG_2, 0x02);
temp_data = temp_data | 0x80;/* 0x40 */
@@ -1920,7 +1973,10 @@ int aml_audiomode_autodet(struct v4l2_frontend *v4l2_fe)
case AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_BG:
case AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_M:
case AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC:
ntsc_signal = true;
broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_M;
break;
#if 0 /* ntsc will try other audio */
broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_M;
atvdemod_init();
temp_data = atv_dmd_rd_reg(APB_BLOCK_ADDR_SIF_STG_2, 0x02);
@@ -1928,7 +1984,7 @@ int aml_audiomode_autodet(struct v4l2_frontend *v4l2_fe)
atv_dmd_wr_reg(APB_BLOCK_ADDR_SIF_STG_2, 0x02, temp_data);
/* pr_err("%s, SECAM ,audio set SECAM_L\n", __func__); */
return broad_std;
#endif
case AML_ATV_DEMOD_VIDEO_MODE_PROP_SECAM_L:
case AML_ATV_DEMOD_VIDEO_MODE_PROP_SECAM_DK2:
case AML_ATV_DEMOD_VIDEO_MODE_PROP_SECAM_DK3:
@@ -2102,9 +2158,15 @@ int aml_audiomode_autodet(struct v4l2_frontend *v4l2_fe)
broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_M;
cur_std = ID_PAL_M;
p->std = V4L2_COLOR_STD_PAL | V4L2_STD_PAL_M;
p->frequency += 1;
p->audmode = V4L2_STD_PAL_M;
if (!ntsc_signal) {
p->std = V4L2_COLOR_STD_PAL | V4L2_STD_PAL_M;
p->frequency += 1;
p->audmode = V4L2_STD_PAL_M;
} else {
p->std = V4L2_COLOR_STD_NTSC | V4L2_STD_NTSC_M;
p->frequency += 1;
p->audmode = V4L2_STD_NTSC_M;
}
delay_ms = delay_ms_default;
break;
@@ -2132,32 +2194,37 @@ int aml_audiomode_autodet(struct v4l2_frontend *v4l2_fe)
/* enable audio detect function */
temp_data = atv_dmd_rd_reg(APB_BLOCK_ADDR_SIF_STG_2, 0x02);
temp_data = temp_data | 0x80;/* 0x40 */
temp_data = temp_data | 0x87;/* 0x40 */
atv_dmd_wr_reg(APB_BLOCK_ADDR_SIF_STG_2, 0x02, temp_data);
usleep_range(delay_ms * 1000, delay_ms * 1000 + 100);
carrier_lock_count = 0;
/* ----------------judgment signal state--------------------- */
i = 4;
has_audio = false;
while (i--) {
retrieve_vpll_carrier_lock(&lock);
if (lock == 0)
line_lock = atv_dmd_rd_byte(APB_BLOCK_ADDR_VDAGC, 0x4f);
if (lock == 0 && (line_lock & 0x10) == 0) {
has_audio = true;
break;
carrier_lock_count++;
if (carrier_lock_count >= 20) {
pr_err("%s step2, retrieve_vpll_carrier_lock failed\n",
__func__);
/* return broad_std; */
}
usleep_range(6000, 9000);
}
/* ----------------read carrier_power--------------------- */
for (i = 0; i < 100; i++) {
carrier_power =
atv_dmd_rd_reg(APB_BLOCK_ADDR_SIF_STG_2, 0x03);
carrier_power_max += carrier_power;
if (has_audio) {
for (i = 0; i < 100; i++) {
carrier_power = atv_dmd_rd_reg(
APB_BLOCK_ADDR_SIF_STG_2, 0x03);
carrier_power_max += carrier_power;
}
carrier_power = carrier_power_max/i;
} else {
carrier_power = 0;
pr_err("[%s] pll and line unlock.\n", __func__);
}
carrier_power = carrier_power_max/i;
carrier_power_max = 0;
pr_err("[%s] [num:%d] [broad_std:%d] audio carrier power: %lu. @@@@@@@@@@\n",
__func__, num, broad_std, carrier_power);
@@ -2170,7 +2237,7 @@ int aml_audiomode_autodet(struct v4l2_frontend *v4l2_fe)
void aml_audio_valume_gain_set(unsigned int audio_gain)
{
unsigned long audio_gain_data, temp_data;
unsigned long audio_gain_data = 0, temp_data = 0;
if (audio_gain > 0xfff) {
pr_err("Error: atv in gain max 7.998, min 0.002! gain = value/512\n");
@@ -2185,7 +2252,7 @@ void aml_audio_valume_gain_set(unsigned int audio_gain)
unsigned int aml_audio_valume_gain_get(void)
{
unsigned long audio_gain_data;
unsigned long audio_gain_data = 0;
audio_gain_data = atv_dmd_rd_word(APB_BLOCK_ADDR_MONO_PROC, 0x52);
audio_gain_data = audio_gain_data & 0xfff;
@@ -2194,7 +2261,7 @@ unsigned int aml_audio_valume_gain_get(void)
void aml_fix_PWM_adjust(int enable)
{
unsigned long temp_data;
unsigned long temp_data = 0;
/*
* temp_data = atv_dmd_rd_byte(APB_BLOCK_ADDR_AGC_PWM, 0x08);
* temp_data = temp_data | 0x01;
@@ -2215,16 +2282,15 @@ void aml_fix_PWM_adjust(int enable)
void aml_audio_overmodulation(int enable)
{
static int ov_flag;
unsigned long tmp_v;
unsigned long tmp_v1;
unsigned long tmp_v = 0;
unsigned long tmp_v1 = 0;
u32 Broadcast_Standard = broad_std;
if (enable && Broadcast_Standard ==
AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_DK) {
tmp_v = atv_dmd_rd_long(APB_BLOCK_ADDR_SIF_STG_2, 0x28);
tmp_v = tmp_v&0xffff;
if (tmp_v >= 0x10 && ov_flag == 0) {
if (tmp_v > 0x10 && audio_atv_ov_flag == 0) {
tmp_v1 =
atv_dmd_rd_long(APB_BLOCK_ADDR_SIF_STG_2, 0);
tmp_v1 = (tmp_v1&0xffffff)|(1<<24);
@@ -2232,19 +2298,12 @@ void aml_audio_overmodulation(int enable)
atv_dmd_wr_long(APB_BLOCK_ADDR_SIF_STG_2,
0x14, 0x8000015);
atv_dmd_wr_long(APB_BLOCK_ADDR_SIF_STG_2,
0x1c, 0x0f000);
} else if (tmp_v >= 0x2500 && ov_flag == 0) {
tmp_v1 = atv_dmd_rd_long(APB_BLOCK_ADDR_SIF_STG_2, 0);
tmp_v1 = (tmp_v1&0xffffff)|(1<<24);
atv_dmd_wr_long(APB_BLOCK_ADDR_SIF_STG_2, 0, tmp_v1);
atv_dmd_wr_long(APB_BLOCK_ADDR_SIF_STG_2,
0x14, 0xf400015);
atv_dmd_wr_long(APB_BLOCK_ADDR_SIF_STG_2,
0x18, 0xc000);
0x18, 0x7ffff);
atv_dmd_wr_long(APB_BLOCK_ADDR_SIF_STG_2,
0x1c, 0x0f000);
ov_flag = 1;
} else if (tmp_v <= 0x10 && ov_flag == 1) {
atvaudio_reg_write(0x0);
audio_atv_ov_flag = 1;
} else if (tmp_v <= 0x10 && audio_atv_ov_flag == 1) {
tmp_v1 = atv_dmd_rd_long(APB_BLOCK_ADDR_SIF_STG_2, 0);
tmp_v1 = (tmp_v1&0xffffff)|(0<<24);
atv_dmd_wr_long(APB_BLOCK_ADDR_SIF_STG_2, 0, tmp_v1);
@@ -2254,7 +2313,8 @@ void aml_audio_overmodulation(int enable)
0x18, 0xc000);
atv_dmd_wr_long(APB_BLOCK_ADDR_SIF_STG_2,
0x1c, 0x1f000);
ov_flag = 0;
atvaudio_reg_write(0x7);
audio_atv_ov_flag = 0;
}
}
}

View File

@@ -64,6 +64,7 @@ extern void read_version_register(void);
extern void check_communication_interface(void);
extern void power_on_receiver(void);
extern void atv_dmd_misc(void);
extern void atv_dmd_ring_filter(bool on);
extern void configure_receiver(int Broadcast_Standard,
unsigned int Tuner_IF_Frequency,
int Tuner_Input_IF_inverted, int GDE_Curve,