Commit 938f11fa authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] drx-j: Fix qam/256 mode

QAM/256 currently doesn't work, as the code is only called if
channel->mirror is DRX_MIRROR_AUTO, but a prevous if prevents
this condition to happen.

While here, returns -EINVAL to not supported QAM modes and
simplify the code, reducing the number of indents.
Acked-by: default avatarDevin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 096c8fac
...@@ -10415,107 +10415,122 @@ set_qam_channel(struct drx_demod_instance *demod, ...@@ -10415,107 +10415,122 @@ set_qam_channel(struct drx_demod_instance *demod,
switch (channel->constellation) { switch (channel->constellation) {
case DRX_CONSTELLATION_QAM16: case DRX_CONSTELLATION_QAM16:
case DRX_CONSTELLATION_QAM32: case DRX_CONSTELLATION_QAM32:
case DRX_CONSTELLATION_QAM64:
case DRX_CONSTELLATION_QAM128: case DRX_CONSTELLATION_QAM128:
return -EINVAL;
case DRX_CONSTELLATION_QAM64:
case DRX_CONSTELLATION_QAM256: case DRX_CONSTELLATION_QAM256:
if (ext_attr->standard != DRX_STANDARD_ITU_B)
return -EINVAL;
ext_attr->constellation = channel->constellation; ext_attr->constellation = channel->constellation;
if (channel->mirror == DRX_MIRROR_AUTO) if (channel->mirror == DRX_MIRROR_AUTO)
ext_attr->mirror = DRX_MIRROR_NO; ext_attr->mirror = DRX_MIRROR_NO;
else else
ext_attr->mirror = channel->mirror; ext_attr->mirror = channel->mirror;
rc = set_qam(demod, channel, tuner_freq_offset, QAM_SET_OP_ALL); rc = set_qam(demod, channel, tuner_freq_offset, QAM_SET_OP_ALL);
if (rc != 0) { if (rc != 0) {
pr_err("error %d\n", rc); pr_err("error %d\n", rc);
goto rw_error; goto rw_error;
} }
if ((ext_attr->standard == DRX_STANDARD_ITU_B) && if (channel->constellation == DRX_CONSTELLATION_QAM64)
(channel->constellation == DRX_CONSTELLATION_QAM64)) { rc = qam64auto(demod, channel, tuner_freq_offset,
rc = qam64auto(demod, channel, tuner_freq_offset, &lock_status); &lock_status);
else
rc = qam256auto(demod, channel, tuner_freq_offset,
&lock_status);
if (rc != 0) {
pr_err("error %d\n", rc);
goto rw_error;
}
break;
case DRX_CONSTELLATION_AUTO: /* for channel scan */
if (ext_attr->standard == DRX_STANDARD_ITU_B) {
u16 qam_ctl_ena = 0;
auto_flag = true;
/* try to lock default QAM constellation: QAM256 */
channel->constellation = DRX_CONSTELLATION_QAM256;
ext_attr->constellation = DRX_CONSTELLATION_QAM256;
if (channel->mirror == DRX_MIRROR_AUTO)
ext_attr->mirror = DRX_MIRROR_NO;
else
ext_attr->mirror = channel->mirror;
rc = set_qam(demod, channel, tuner_freq_offset,
QAM_SET_OP_ALL);
if (rc != 0) { if (rc != 0) {
pr_err("error %d\n", rc); pr_err("error %d\n", rc);
goto rw_error; goto rw_error;
} }
} rc = qam256auto(demod, channel, tuner_freq_offset,
&lock_status);
if ((ext_attr->standard == DRX_STANDARD_ITU_B) &&
(channel->mirror == DRX_MIRROR_AUTO) &&
(channel->constellation == DRX_CONSTELLATION_QAM256)) {
rc = qam256auto(demod, channel, tuner_freq_offset, &lock_status);
if (rc != 0) { if (rc != 0) {
pr_err("error %d\n", rc); pr_err("error %d\n", rc);
goto rw_error; goto rw_error;
} }
}
break; if (lock_status >= DRX_LOCKED) {
case DRX_CONSTELLATION_AUTO: /* for channel scan */ channel->constellation = DRX_CONSTELLATION_AUTO;
if (ext_attr->standard == DRX_STANDARD_ITU_B) { break;
auto_flag = true; }
/* try to lock default QAM constellation: QAM64 */
channel->constellation = DRX_CONSTELLATION_QAM256; /* QAM254 not locked. Try QAM64 constellation */
ext_attr->constellation = DRX_CONSTELLATION_QAM256; channel->constellation = DRX_CONSTELLATION_QAM64;
ext_attr->constellation = DRX_CONSTELLATION_QAM64;
if (channel->mirror == DRX_MIRROR_AUTO) if (channel->mirror == DRX_MIRROR_AUTO)
ext_attr->mirror = DRX_MIRROR_NO; ext_attr->mirror = DRX_MIRROR_NO;
else else
ext_attr->mirror = channel->mirror; ext_attr->mirror = channel->mirror;
rc = set_qam(demod, channel, tuner_freq_offset, QAM_SET_OP_ALL);
rc = DRXJ_DAP.read_reg16func(demod->my_i2c_dev_addr,
SCU_RAM_QAM_CTL_ENA__A,
&qam_ctl_ena, 0);
if (rc != 0) { if (rc != 0) {
pr_err("error %d\n", rc); pr_err("error %d\n", rc);
goto rw_error; goto rw_error;
} }
rc = qam256auto(demod, channel, tuner_freq_offset, &lock_status); rc = DRXJ_DAP.write_reg16func(demod->my_i2c_dev_addr,
SCU_RAM_QAM_CTL_ENA__A,
qam_ctl_ena & ~SCU_RAM_QAM_CTL_ENA_ACQ__M, 0);
if (rc != 0) { if (rc != 0) {
pr_err("error %d\n", rc); pr_err("error %d\n", rc);
goto rw_error; goto rw_error;
} }
rc = DRXJ_DAP.write_reg16func(demod->my_i2c_dev_addr,
SCU_RAM_QAM_FSM_STATE_TGT__A,
0x2, 0);
if (rc != 0) {
pr_err("error %d\n", rc);
goto rw_error;
} /* force to rate hunting */
if (lock_status < DRX_LOCKED) { rc = set_qam(demod, channel, tuner_freq_offset,
/* QAM254 not locked -> try to lock QAM64 constellation */ QAM_SET_OP_CONSTELLATION);
channel->constellation = if (rc != 0) {
DRX_CONSTELLATION_QAM64; pr_err("error %d\n", rc);
ext_attr->constellation = goto rw_error;
DRX_CONSTELLATION_QAM64; }
if (channel->mirror == DRX_MIRROR_AUTO) rc = DRXJ_DAP.write_reg16func(demod->my_i2c_dev_addr,
ext_attr->mirror = DRX_MIRROR_NO; SCU_RAM_QAM_CTL_ENA__A,
else qam_ctl_ena, 0);
ext_attr->mirror = channel->mirror; if (rc != 0) {
{ pr_err("error %d\n", rc);
u16 qam_ctl_ena = 0; goto rw_error;
rc = DRXJ_DAP.read_reg16func(demod->my_i2c_dev_addr, SCU_RAM_QAM_CTL_ENA__A, &qam_ctl_ena, 0); }
if (rc != 0) {
pr_err("error %d\n", rc);
goto rw_error;
}
rc = DRXJ_DAP.write_reg16func(demod->my_i2c_dev_addr, SCU_RAM_QAM_CTL_ENA__A, qam_ctl_ena & ~SCU_RAM_QAM_CTL_ENA_ACQ__M, 0);
if (rc != 0) {
pr_err("error %d\n", rc);
goto rw_error;
}
rc = DRXJ_DAP.write_reg16func(demod->my_i2c_dev_addr, SCU_RAM_QAM_FSM_STATE_TGT__A, 0x2, 0);
if (rc != 0) {
pr_err("error %d\n", rc);
goto rw_error;
} /* force to rate hunting */
rc = set_qam(demod, channel, tuner_freq_offset, QAM_SET_OP_CONSTELLATION); rc = qam64auto(demod, channel, tuner_freq_offset,
if (rc != 0) { &lock_status);
pr_err("error %d\n", rc); if (rc != 0) {
goto rw_error; pr_err("error %d\n", rc);
} goto rw_error;
rc = DRXJ_DAP.write_reg16func(demod->my_i2c_dev_addr, SCU_RAM_QAM_CTL_ENA__A, qam_ctl_ena, 0);
if (rc != 0) {
pr_err("error %d\n", rc);
goto rw_error;
}
}
rc = qam64auto(demod, channel, tuner_freq_offset, &lock_status);
if (rc != 0) {
pr_err("error %d\n", rc);
goto rw_error;
}
} }
channel->constellation = DRX_CONSTELLATION_AUTO; channel->constellation = DRX_CONSTELLATION_AUTO;
} else if (ext_attr->standard == DRX_STANDARD_ITU_C) { } else if (ext_attr->standard == DRX_STANDARD_ITU_C) {
u16 qam_ctl_ena = 0;
channel->constellation = DRX_CONSTELLATION_QAM64; channel->constellation = DRX_CONSTELLATION_QAM64;
ext_attr->constellation = DRX_CONSTELLATION_QAM64; ext_attr->constellation = DRX_CONSTELLATION_QAM64;
auto_flag = true; auto_flag = true;
...@@ -10524,43 +10539,49 @@ set_qam_channel(struct drx_demod_instance *demod, ...@@ -10524,43 +10539,49 @@ set_qam_channel(struct drx_demod_instance *demod,
ext_attr->mirror = DRX_MIRROR_NO; ext_attr->mirror = DRX_MIRROR_NO;
else else
ext_attr->mirror = channel->mirror; ext_attr->mirror = channel->mirror;
{ rc = DRXJ_DAP.read_reg16func(demod->my_i2c_dev_addr,
u16 qam_ctl_ena = 0; SCU_RAM_QAM_CTL_ENA__A,
rc = DRXJ_DAP.read_reg16func(demod->my_i2c_dev_addr, SCU_RAM_QAM_CTL_ENA__A, &qam_ctl_ena, 0); &qam_ctl_ena, 0);
if (rc != 0) { if (rc != 0) {
pr_err("error %d\n", rc); pr_err("error %d\n", rc);
goto rw_error; goto rw_error;
} }
rc = DRXJ_DAP.write_reg16func(demod->my_i2c_dev_addr, SCU_RAM_QAM_CTL_ENA__A, qam_ctl_ena & ~SCU_RAM_QAM_CTL_ENA_ACQ__M, 0); rc = DRXJ_DAP.write_reg16func(demod->my_i2c_dev_addr,
if (rc != 0) { SCU_RAM_QAM_CTL_ENA__A,
pr_err("error %d\n", rc); qam_ctl_ena & ~SCU_RAM_QAM_CTL_ENA_ACQ__M, 0);
goto rw_error; if (rc != 0) {
} pr_err("error %d\n", rc);
rc = DRXJ_DAP.write_reg16func(demod->my_i2c_dev_addr, SCU_RAM_QAM_FSM_STATE_TGT__A, 0x2, 0); goto rw_error;
if (rc != 0) { }
pr_err("error %d\n", rc); rc = DRXJ_DAP.write_reg16func(demod->my_i2c_dev_addr,
goto rw_error; SCU_RAM_QAM_FSM_STATE_TGT__A,
} /* force to rate hunting */ 0x2, 0);
if (rc != 0) {
pr_err("error %d\n", rc);
goto rw_error;
} /* force to rate hunting */
rc = set_qam(demod, channel, tuner_freq_offset, QAM_SET_OP_CONSTELLATION); rc = set_qam(demod, channel, tuner_freq_offset,
if (rc != 0) { QAM_SET_OP_CONSTELLATION);
pr_err("error %d\n", rc); if (rc != 0) {
goto rw_error; pr_err("error %d\n", rc);
} goto rw_error;
rc = DRXJ_DAP.write_reg16func(demod->my_i2c_dev_addr, SCU_RAM_QAM_CTL_ENA__A, qam_ctl_ena, 0);
if (rc != 0) {
pr_err("error %d\n", rc);
goto rw_error;
}
} }
rc = qam64auto(demod, channel, tuner_freq_offset, &lock_status); rc = DRXJ_DAP.write_reg16func(demod->my_i2c_dev_addr,
SCU_RAM_QAM_CTL_ENA__A,
qam_ctl_ena, 0);
if (rc != 0) {
pr_err("error %d\n", rc);
goto rw_error;
}
rc = qam64auto(demod, channel, tuner_freq_offset,
&lock_status);
if (rc != 0) { if (rc != 0) {
pr_err("error %d\n", rc); pr_err("error %d\n", rc);
goto rw_error; goto rw_error;
} }
channel->constellation = DRX_CONSTELLATION_AUTO; channel->constellation = DRX_CONSTELLATION_AUTO;
} else { } else {
channel->constellation = DRX_CONSTELLATION_AUTO;
return -EINVAL; return -EINVAL;
} }
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment